Orionsbelter Posted March 29, 2010 Share Posted March 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/ Share on other sites More sharing options...
Deoctor Posted March 29, 2010 Share Posted March 29, 2010 try using the alegro cart Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033399 Share on other sites More sharing options...
Orionsbelter Posted March 29, 2010 Author Share Posted March 29, 2010 What is that? could you post a link please? Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033403 Share on other sites More sharing options...
Orionsbelter Posted March 29, 2010 Author Share Posted March 29, 2010 Thank you for your suggestion but i would rather not use a program over personal coding Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033404 Share on other sites More sharing options...
Deoctor Posted March 29, 2010 Share Posted March 29, 2010 Thank you for your suggestion but i would rather not use a program over personal coding believe me, u would not try to take risk of recreating it all again..it would be more easier if u use this code.. http://www.alegrocart.com/ this is the link.. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033409 Share on other sites More sharing options...
KevinM1 Posted March 29, 2010 Share Posted March 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033421 Share on other sites More sharing options...
Deoctor Posted March 29, 2010 Share Posted March 29, 2010 i doesnot mean that it is difficult, what i meant is why do u need to reinvent the wheel.. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033428 Share on other sites More sharing options...
ignace Posted March 29, 2010 Share Posted March 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033480 Share on other sites More sharing options...
Orionsbelter Posted March 29, 2010 Author Share Posted March 29, 2010 I when the float left way it works how every each of the containers are in another container which it seems to now float over the top of how can i make it push down the container when i fill it with the floated boxes? Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033506 Share on other sites More sharing options...
Orionsbelter Posted March 29, 2010 Author Share Posted March 29, 2010 Sorted it with the clear:both Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033516 Share on other sites More sharing options...
Orionsbelter Posted March 29, 2010 Author Share Posted March 29, 2010 Thank you all Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033519 Share on other sites More sharing options...
KevinM1 Posted March 29, 2010 Share Posted March 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033742 Share on other sites More sharing options...
ignace Posted March 29, 2010 Share Posted March 29, 2010 I must be getting blind (or really tired) Where the div's class sets its size and floats it to the left. I didn't even see this line Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033751 Share on other sites More sharing options...
KevinM1 Posted March 29, 2010 Share Posted March 29, 2010 I must be getting blind (or really tired) Where the div's class sets its size and floats it to the left. I didn't even see this line That's okay... I still have the injected linebreak there. Quote Link to comment https://forums.phpfreaks.com/topic/196851-how-do-i-do-this-its-annoying-now/#findComment-1033755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.