While loop and table in PHP MYSQL?

ibrahiemrafiq

New member
My webiste is having a problem. It is calling the data from a database. I want this data to be displayed in a table. It is displaying only one record in the table, the others it is leaving outside the table aas if they are a paragraph. Can you help?

include ("connection.php");

// (3) Create a query
$query = "SELECT User_ID, forename, surname, email, radiom, genre, username FROM User_Details WHERE User_ID > 0 ORDER BY User_ID ASC";

// (4) Run the query on the table through the connection
$result = mysql_query ($query);

// (5) While there are still rows in the result set, fetch the current

{
// (6) Print out each element in $row, that is, print the values of


print "<table border = 5 >";
print "<tr><th>ID</th><th>Forename</th><th>Surname</th><th>Email Address</th><th>Gender</th><th>Genre</th><th>Username</th></tr>";
while ($row = mysql_fetch_array($result))
{
print " <tr>";
print " <td>" . $row["User_ID"]. "</td>";
print " <td>" . $row["forename"] . "</td>";
print " <td>" . $row["surname"]. "</td>";
print " <td>" . $row["email"]. "</td>";
print " <td>" . $row["radiom"]. "</td>";
print " <td>" . $row["genre"]. "</td>";
print " <td>" . $row["username"]. "</td>";
print " </tr>";

print "</table>";
}

"</div>";

}

?>
 
Back
Top