Grid output using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zander213
Forum Newbie
Posts: 13
Joined: Mon Aug 23, 2004 1:46 pm

Grid output using php

Post by zander213 »

Hello - I am using dreamweaver to design some php pages, and I was wondering how I can create an output of products that are 4 products wide by 4 high (in a grid)...

So far I can make a list of the products vertically, but im not sure about the design for this type of grid layout... Is there a php script that will display the "next" item at a specific location?

Thanks!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

after searching the forums for 10 sec I found

Code: Select all

$result = mysql_query("SELECT * FROM pics");
$loop=1;

while($row = mysql_fetch_assoc($result)){

if($loop==1){
echo "<tr>";
}

echo "<td><img src="$row[image]"></td>";

if($loop==4){
echo "</tr>";
$loop = 0
}

$loop++;
you'll obviously have to modify it for your needs
Post Reply