August 23rd, 2000, 04:46 PM
-
I have a PHP program that first of all, assigns an ID number to an image, then uploads the image into a directory on the server and gives it the ID number as a name (for example, 365912546.gif) and finally adds a database record containing the image ID number and the time the image is added. I then want to have a program that retrieves the images and prints them in an HTML table. But, here's the catch: I want there to be four images on each table row. So, the process that retrieves the images and puts them in a table would run four times, then restart. I've no idea how to do this at all: hopefully someone reading this does! Please help me out if you can.
--------------------------------------------
Alex
(http://www.alex-greg.co.uk)
August 23rd, 2000, 06:33 PM
-
Do you mean that there would be four cells to each row across? This is how I do it and it wprks great
//Set this to be the number you want across
$rows = 4;
$i = 1;
print '<table><tr>';
while ($row = mysql_fetch_array($result)) {
if (is_int($i / $rows)) {
print '<td><img src="'. $row["imagefield"] .'"></td></tr><tr>';
}
else {
print '<td><img src="'. $row["imagefield"] .'"></td>';
}
}
print '</tr></table>';