farhad Posted August 10, 2010 Share Posted August 10, 2010 Hi! I'm using, mysql ver: 5.1.36 php ver: 5.3.0 I would really need your help with this one. I´m traying to show 2-3 item next to each other in the browser. The problem is that i have no idea how to construct my while loop! I´ll show u my code below, it shows only one item at a time. I´m trying to create somthing like the pic attached. Thanks! function show_products(){ $query = "SELECT * FROM pages LIMIT 5 "; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ //get the image size of the picture and load it into an array $image = getimagesize("uploads/{$row['image_link']}"); $output = "<div class=\"index-prducts\">"; $output .= "<table class=\"index\">"; $output .= "<tr>"; $output .= "<th ><p><a href=\"index.php?page={$row['id']}\">{$row['menu_name']}</a></p></th>"; if($row['price'] !=0){ $output .= "<th class=\"price\"><a href=\"index.php?page={$row['id']}\"></a></th>"; $output .= "<th class=\"price\"><p><a href=\"index.php?page={$row['id']}\">Pris:</a></p></th>"; } $output .= "</tr>"; $output .= "<td>" . "<p><a href=\"index.php?page={$row['id']}\">{$row['description']} <br/><br/><img src=\"images/ikoner/read_more.jpg\" border=\"0\" align=\"right\"><br/> </a></p>" ."</td>"; $output .= "<td width=\"60\" >" . "<img src=\"uploads/" . $row['image_link'] . "\""; $output .= imageResize($image[0],$image[1], 100); $output .= ">"; if($row['price'] !=0){ $output .= "<td class=\"price\">" .$row['price'] . "kr"; } $output .= "</td>"; $output .= "</tr>"; $output .= "</table>"; $output .= "</div>"; echo $output; } } [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/210379-mysql-show-items-same-as-ebay/ Share on other sites More sharing options...
farhad Posted August 10, 2010 Author Share Posted August 10, 2010 Pehaps it was to much to read, let me make it easier. $query = "SELECT * FROM pages LIMIT 5 "; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $output = "<div>"; $output .= "<table class=\"index\">"; $output .= "<tr>"; $output .= "<th ><p><a href=\"index.php?page={$row['id']}\">{$row['menu_name']}</a></p></th>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td><p><a href=\"index.php?page={$row['id']}\">{$row['description']}</a></td>"; $output .= "</tr>"; $output .= "</table>"; $output .= "</div>"; echo $output; } Quote Link to comment https://forums.phpfreaks.com/topic/210379-mysql-show-items-same-as-ebay/#findComment-1097827 Share on other sites More sharing options...
jdavidbakr Posted August 12, 2010 Share Posted August 12, 2010 DIVs default to displaying in block form, which means that they fill the width of the page. I assume that's what your problem is, that the entries are just displaying one on top of the other instead of side-by-side. You're probably wanting to style the DIV in such a way that it allows two to be next to each other. You could try "float: left" and a fixed width, or change your strategy to use tables and close/reopen the <tr> every second entry. Quote Link to comment https://forums.phpfreaks.com/topic/210379-mysql-show-items-same-as-ebay/#findComment-1098505 Share on other sites More sharing options...
farhad Posted August 13, 2010 Author Share Posted August 13, 2010 I fixed my problem like 30 min before your post... after 6h of googling on the internet and same time traying to reconstruct my table "not a good day". Anyway thanks for the help. I did resolve my problem with divs, I used "float to right". CSS is not my strongest side. perhaps block is a better option i don´t know. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/210379-mysql-show-items-same-as-ebay/#findComment-1098671 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.