Jump to content

How to display data from a mysql table in rows of 4?


Stalingrad

Recommended Posts

Hi! This is probably simple, and I know it is, I just need my memory refreshed at this point. I will show you the data I want to grab in a minute. I want to display the data like this:

 

NAME    NAME    NAME  NAME

IMAGE  IMAGE  IMAGE  IMAGE

 

 

NAME  NAME  NAME  NAME

IMAGE  IMAGE  IMAGE IMAGE

 

etc...(it will ocntinue on with whatever is in the table, and stop when the data stops). :)

 

I know there will be a simple table involved in this too.

 

Here is the table information and query:

 

 

$infoq = "SELECT * FROM items WHERE itemid='$umiid'";
$info = mysql_query($infoq);
while($row = mysql_fetch_array($info)) {
$myname = $row['name'];
$myid = $row['itemid'];
$myimage = $row['image'];
$mydesc = $ow['description'];
$myrarity = $row['rarity'];

echo "$myname<br><img src=/images/items/$myimage>";
}

 

I am wanting to display the "myname" as the name, and the "my image" as the image, underneath the name.

 

Thank you for your help in advance! :)

Something like...

$i = 1;

while($row = mysql_fetch_array($info)) {
$myname = $row['name'];
$myid = $row['itemid'];
$myimage = $row['image'];
$mydesc = $ow['description'];
$myrarity = $row['rarity'];

echo "<div style=\"float:left;\">$myname<br><img src=/images/items/$myimage></div>";

if ($i % 4 == 0) {
	echo '<br style="clear:both;" />';
}

$i++;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.