www.webdeveloper.com
Results 1 to 3 of 3

Thread: Printing mysql into table rows

  1. #1
    Join Date
    Jun 2006
    Location
    Doncaster
    Posts
    78

    Printing mysql into table rows

    Hi there,
    I have some code based upon tizag's tutorial at http://www.tizag.com/mysqlTutorial/mysqlselect.php which I am trying to alter.

    Essentiallyu, what I am trying to do is show the output from four fields in a table.

    This is the php:
    PHP Code:
    <?php
    $query 
    "SELECT * FROM `cast`";
    $castlist mysql_query($query);
    //mysql_close();
    echo "<table border='1'>";
    echo 
    "<tr> <th>First Name</th> <th>Second Name</th> <th>Age</th> <th>Role</th></tr>";
    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array$castlist )) {
        
    // Print out the contents of each row into a table
        
    echo "<tr><td>"
        echo 
    $row['fname'];
        echo 
    "</td><td>"
        echo 
    $row['sname'];
        echo 
    "</td></tr>";
        echo 
    $row['type'];
        echo 
    "</td></tr>";
        echo 
    $row['age'];
        echo 
    "</td></tr>";   


    echo 
    "</table>";
    ?>
    Currently, the script creates the correct headers, and two columns (fname, sname), but the shows the output from the last two outside the table.

    Can anyone show me where I am going wrong?

  2. #2
    Join Date
    Aug 2007
    Location
    Leeds, Yorkshire, England
    Posts
    387
    </tr> ends the row, and you have too many </tr>'s

  3. #3
    Join Date
    Jun 2006
    Location
    Doncaster
    Posts
    78
    Yes, thank-you!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles