create an html table from mysql db

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Post by Oleg Butuzov » Thu Oct 17, 2002 10:35 am

$query=mysql_query("SELECT * FROM `table`");

echo "<table width=800 border=0>";
while($data=mysql_fetch_array($query))
{
echo"<tr><td>$data[1]</td><td>$data[2]</Td><td>$data[3]</td></tr>";
}
echo "</table>";

Jay

Post by Jay » Fri Oct 18, 2002 1:16 am

We will help you with your scripts, but not write them for you! Pejone's solution is the standard method.

Begin your table as normal (heading cells etc), then call the results as a row. For every row print a row in your table containing the results, and then end the table, voila!

If you can't structure the query correctly, then try to make it into an array and use this array to generate the table. It's all about learning how to use loops and generate a table row each time!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests