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! :)

Link to comment
Share on other sites

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++;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.