Originally Posted by cscgal
I don't know PHP for anything but the following is code for one row ...
So now, perhaps use code like the following? Keep in mind I'm NOT a php programmer.
echo "<table><tr>";
while ($row = mysql_fetch_array($result))
{
echo "<td><a HREF=images/ingame/".$row['big']." TARGET=_blank><img src=images/ingame/thumbs/".$row['thumb']." border=0 alt=".$row['big']."></a></td>"; // display your results as you see fit here.
if (($row % 3) == 0)
{ echo "</tr><tr>"; }
}
</tr></table>
Keep also in mind that you need to add "empty" cells if you want to display images in a table of 3x4.
I you have a total of 10 records, and the table has 3 rows, 4 columns, then the last row of the table has only 2 columns in it. You need to add <td></td> (or <td> </td>) cells to fill up the row.
I've made an example at
http://quaedackers.homeip.net/testsite/table_format.php
As you can see I use 2 nested loops. 1 for the rows, and 1 for the columns. By checking if the row-object (or array) contains any data (it must NOT be false) then you can write the data in the cell. If the object equals false, then you need to write an empty cell.
[php]
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n";
for($row=0; $row<$rowCount; $row++){ // create the rows in a nice loop
echo "<tr>";
for($col=0; $col<$colCount; $col++){ // create the columns in a nice nested loop
echo "<td width=\"30\" align=\"center\">";
if($db_row = mysql_fetch_object($result))
// fetch the results in an object and thest if there is data.
// (if there is no data, $db_row will be 'false')
{
echo htmlentities($db_row->some_field); // There is data, display it!
}
else
{
echo " "; // There was no data. Write a to create an 'empty' cell
}
echo "</td>"; // close the cell
}
echo "</tr>\n"; // close the row
}
echo "</table>\n"; // close the table
[/php]
/ Patrick