PHP newbie here again looking for some more help. I am trying to create a html table using information queried from a database. I would like three columns and the number of rows would be dynamic based on information gathered during the query. Briefly, it would look like:
picture1 | picture2 | picture3
==================
lablel1 | label2 | label3
==================
picture4 | etc. etc.
What I am getting right now is:
picture1 | picture1 | picture1
==================
picture2 | picture2 | picture2
The loop is working, if only incorrectly; and I can't figure out how to apply the corresponding labels on the next row. Here's my code:
if (($result)||(mysql_errno == 0))
{
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
if (mysql_num_rows($result)>0)
{
//display the data
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
//loop thru the serials to create three columns
$i = 0;
while ($i < '3')
{
echo "<td><img src='/images/{$rows['FileDirectory']}/{$rows['Graphic']}.jpg' width='150' height='112' /></td>";
$i++;
}
echo "</tr>";
}
}else{
echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>";
}
echo "</table>";
}else{
echo "Error in running query :". mysql_error();
}
Any help is appreciated. Thanks.