SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Threaded View

  1. #1
    SitePoint Enthusiast Davve's Avatar
    Join Date
    Jan 2002
    Location
    Norrkoping, SWEDEN
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Divine way of listing?

    I'm a PHP newbie. How can you tell? Well, I have this easy (stupid?) question for you...

    I have my MySQL database with a table with four fields. ID, field1, field2 and field3. Now I want to just list these fields in a nice HTML table. I'm trying to come up with a good while, do..while or for to do this. But my own tries generate so much code. There's got to be one divine way of doing this.

    What's the divine way?

    I could of course use my own code, but I feel that because I'm still a newbie it would be better to look at this super code and use it!




    Edit: my "bad" code
    Which, by the way, isn't working. My for loop works, but my echoes show only: Resource id #3, Resource id #4 and Resource id #3. Why is that?
    PHP Code:
    <table border=0 cellspacing=2 cellpadding=2 width=600>
        <tr>
        <td align=center width=200>
            table_variable        
            </td>
                <td align=center width=200>
                table_innehall
                </td>
                    <td align=center width=200>
                    table_innehall_flash
                    </td>
        </tr>

    <?php
    $i 
    1;

    $table_variabel mysql_query("SELECT variabel FROM text WHERE ID = '$i'");
    $table_innehall mysql_query("SELECT innehall FROM text WHERE ID = '$i'");
    $table_innehall_flash mysql_query("SELECT innehall_flash FROM text WHERE ID = '$i'");

    for (
    $i 1$i <= 3$i++) {

    ?>
        <tr>
            <td align=center>
            <?php echo $table_variabel ?>            
            </td>
                <td align=center>
                <?php echo $table_innehall ?>            
                </td>
                    <td align=center>
                    <?php echo $table_innehall_flash ?>            
                    </td>
        </tr>


    <?php

    }

    ?>

    </table>
    Last edited by Davve; Jun 19, 2002 at 02:47.
    David Andersson Davve
    -MSc in Media Technology and Engineering:
    Working at AdLibris


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •