Page 1 of 1
images from database
Posted: Tue Dec 07, 2010 3:54 pm
by amirbwb
hello i want to display 9 images from my database ...
actually everything is fine but i want to display them : each 3 images on a row and leave space beween them:
ex:
[ ] [ ] [ ]
[ ] [ ] [ ]
[ ] [ ] [ ]
Re: images from database
Posted: Tue Dec 07, 2010 6:44 pm
by califdon
So what is your question?? Do remember, this is a PHP Code forum.
Re: images from database
Posted: Wed Dec 08, 2010 7:20 am
by amirbwb
califdon wrote:So what is your question?? Do remember, this is a PHP Code forum.
my quest is howwwwwwwwwwwww to display each 3 images on a row!!!!!!!
Re: images from database
Posted: Wed Dec 08, 2010 11:12 am
by califdon
amirbwb wrote:califdon wrote:So what is your question?? Do remember, this is a PHP Code forum.
my quest is howwwwwwwwwwwww to display each 3 images on a row!!!!!!!
PHP is a server-side language and plays no part in displaying anything in a browser. If you need to know how to arrange your web page, you should post your question in a forum that deals with HTML. If you already understand how to arrange your web page, then I don't understand why you are asking how to do it.
Re: images from database
Posted: Wed Dec 08, 2010 2:22 pm
by s992
This example will give you a result of
[a1][a2][a3]
[b1][b2][b3]
[c1][c2][c3]
but it will also contain an extra empty <tr></tr> at the bottom of the table. You should be able to work with this to get what you need.
Code: Select all
<?php
$arr = array("a1","a2","a3","b1","b2","b3","c1","c2","c3");
echo "<table><tr>";
$count = 1;
foreach($arr as $cell) {
if($count % 3 == 0) {
echo "<td>$cell</td></tr><tr>";
$count++;
} else {
echo "<td>$cell</td>";
$count++;
}
}
echo "</tr></table>";
?>