Hi there,
I have some code based upon tizag’s tutorial at [url]http://www.tizag.com/mysqlTutorial/mysqlselect.php
Essentiallyu, what I am trying to do is show the output from four fields in a table.
This is the php:
[code=php]<?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?