Generate output tables from MySQL

A

Anonymous

Guest
Hi,

The script below print a content of the MySQL database. The output print a record in a row and when the record finished it prints the next record below it and etc.

How can I generate an automatic table (separation between the records) so I will receive a nice output.

Thanks.

Script:
if ($rowsFound > 0)
{
while ($row = @ mysql_fetch_array($result))
{
print 'ID: '. $row["ID"]. ' ';
#echo "<br><br>\n";
print 'name: '. $row["name"]. ' ';
# echo "<br><br>\n";
print 'gen: '. $row["gen"]. ' ';
echo "<br><br>\n";
}
}
 
I don't if I am sure about what you are asking, but if I'm right, here this should help.
Code:
$query = mysql_query("SELECT * FROM `yourtable` WHERE 1");
while ($row  =  mysql_fetch_array($query))
   	{
        $ID=$row["ID"];
        $name=$row["name"];
        $gen=$row["gen"];

print"<html>\n";
print"<head>\n";
print"</head>\n";
print"<body>\n"; 
print"<center>\n";
print"<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">\n";
print"  <tr>\n";
print"    <td> $ID</td>\n";
print"    <td> $name</td>\n";
print"    <td> $gen</td>\n";
print"  </tr>\n";
print"</table>\n";
print"</center>\n";
print"</body>\n";
print"</html>\n";
    }
?>
 
Thanks for the code and how can I add lines so it will look like excel sheet.

thanks again
 
Back
Top