Page 1 of 1
Displaying Images in a Table
Posted: Wed Feb 15, 2006 6:56 am
by tambourine
Hello, im new to php and i have failed to work out how to display images in a table that consist of 5 rows by 5 columns.
I think a IF loop is needed, but i couldn't seem to any to work
The variable im trying to displays is
Code: Select all
<?php echo $row_blobby['previewpath']; ?>
Im basically trying to get my images to display in a 5 * 5 table.
Hope, someone can help or guide me in the correct direction. Thanks!

Posted: Wed Feb 15, 2006 7:34 am
by AndrewBacca
this is untested but give it ago
Code: Select all
<?php
print "<table>";
for ($i = 0; $i <= 5; $i++) {
if ($i % 5 == 0) {
print "<tr>";
}
print "<td>" . $row_blobby['previewpath'] . "</td>";
if ($i % 5 == 5) {
print "</tr>";
}
}
print "</table>";
?>
hope that helps/works
Posted: Wed Feb 15, 2006 8:21 am
by tambourine
Ok, this code works kinda....
Code: Select all
<?php
print "<table>";
for ($i = 0; $i <= 5; $i++) {
if ($i % 5 == 0) {
print "<tr>";
}
print '<td><img src="http://'.$row_blobby['previewpath'].'" /></td>';
if ($i % 5 == 5) {
print "</tr>";
}
}
print "</table>";
?>
....it displays the same image 5 times accross and 1 time down
Exmaple:
http://www.surgeryofsound.co.uk/mobile- ... all-uk.php
Any more suggestions?
Thank you!
Posted: Wed Feb 15, 2006 8:29 am
by AndrewBacca
I think this should work
Code: Select all
<?php
print "<table>";
for ($i = 0; $i <= 4; $i++) {
if ($i % 5 == 0) {
print "<tr>";
}
print '<td><img src="http://'.$row_blobby['previewpath'].'" /></td>';
if ($i % 5 == 5) {
print "</tr>";
}
}
print "</table>";
?>