Jump to content

HOW DO I DO THIS?? IT'S ANNOYING NOW!


Orionsbelter

Recommended Posts

Hi there i'm trying to do something very simple but do not know how too. Please look at this link http://www.uo.com.au/accessories.cfm?t=/belts/ see the products are in rows on each row there is 4 belts then they start  a new row.

 

I'm building a shop where i want to Echo all products of a certain category for example say am selling belts like the site above.

 

I want echo each product in a div box and the product image inside, i need the script to put each div box next to each other (side by side ) like the link shows. Then after it gets to a fourth belt it should then start a new row of products under it to stop overflowing.

 

Can anybody help?

Link to comment
Share on other sites

I don't see why this is so difficult.

 

You know how to retrieve data from the db, correct?  If so, just do something like:

 

$count = 0;

while($row = mysql_fetch_assoc($result))
{
   if ($count % 4 == 0) { echo '<br /'>; }

   echo '<div class="item"><img src="path/to/image" alt="' . $row['alt'] . '" /></div>';
   ++$count;
}

 

Where the div's class sets its size and floats it to the left.

Link to comment
Share on other sites

I don't see why this is so difficult.

 

You know how to retrieve data from the db, correct?  If so, just do something like:

 

$count = 0;

while($row = mysql_fetch_assoc($result))
{
   if ($count % 4 == 0) { echo '<br /'>; }

   echo '<div class="item"><img src="path/to/image" alt="' . $row['alt'] . '" /></div>';
   ++$count;
}

 

Where the div's class sets its size and floats it to the left.

 

You can also accomplish this by using CSS. Give each div a class so they all have the same width and add float: left; If the total size of your divs is greater than it's containing div then it will be automatically be pushed to the next line.

Link to comment
Share on other sites

I don't see why this is so difficult.

 

You know how to retrieve data from the db, correct?  If so, just do something like:

 

$count = 0;

while($row = mysql_fetch_assoc($result))
{
   if ($count % 4 == 0) { echo '<br /'>; }

   echo '<div class="item"><img src="path/to/image" alt="' . $row['alt'] . '" /></div>';
   ++$count;
}

 

Where the div's class sets its size and floats it to the left.

 

You can also accomplish this by using CSS. Give each div a class so they all have the same width and add float: left; If the total size of your divs is greater than it's containing div then it will be automatically be pushed to the next line.

 

That's true.  I tend to add the linebreak just for completeness' sake.

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.