BCAV_WEB Posted December 8, 2010 Share Posted December 8, 2010 Hi, I'm having a bit of trouble with returning data from the database. It brings back the images etc... correctly, but I need to be able to limit it to two images per, line and then to carriage return. Or using CSS to position them with the correct padding etc... I'm very tired and can't seem to figure it out, which is starting to frustrate me. To see what I mean, go to www.bikescarsandvans.co.uk/test.php and select the drop down menu. And see coding for particular section. Any help will be much appericated, I know a good sleep would probaly help but don't have time for that right now :'( print " </td> <td colspan='2'> <div id='CollapsiblePanel" . $car_row["id"] . "' class='CollapsiblePanel'> <div class='CollapsiblePanelTab' tabindex='0'><img class='drop' src='images/drop_down.jpg' alt='Go' /></div> <div class='CollapsiblePanelContent'> <p> <div class='title_tabs'>Standard Specification</div> <table class='standard_spec'> <tr> <th> Engine Size: </th> <td> ".$car_row["engine"]." </td> </tr> <tr> <th> BHP: </th> <td> ".$car_row["bhp"]." </td> </tr> <tr> <th> Fuel Type: </th> <td> ".$car_row["fuel_type"]." </td> </tr> <tr> <th> Number of Doors: </th> <td> ".$car_row["no_doors"]." </td> </tr> <tr> <th> Wheels: </th> <td> ".$car_row["wheels"]." </td> </tr> </table> </p> "; //QUERY FOR TITLE START $query_title = "SELECT * FROM extras JOIN car_to_extra ON (car_to_extra.extras_id = extras.id) WHERE car_to_extra.car_id = '{$car_row['id']}' ORDER BY extras.price ASC"; $title_results = mysql_query($query_title) or die ("Error in query: $query_title. ".mysql_error()); $current_heading = ''; while ($title_row = @ mysql_fetch_array($title_results )) { if ($current_heading != $title_row["title"]) { // The heading has changed from before, so print the new heading here. $current_heading = $title_row["title"]; print " <p> <div class='title_tabs'>" . $title_row["title"] . "</div> "; } ?> <a class='data' href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $title_row["info"] . "<br/>(£" . $title_row["price"] . ")"; ?>");return false'> <?php print " <img class='extra_img' src=\"". $title_row["img"] ."\" alt='" . $title_row["img_alt"] . "' /></a> </p>"; } //QUERY FOR TITLE END print " </div> </div> <script type='text/javascript'> <!-- var CollapsiblePanel" . $car_row["id"] . " = new Spry.Widget.CollapsiblePanel('CollapsiblePanel" . $car_row["id"] . "', {contentIsOpen:false}); //--> </script> </td> </tr> "; Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/ Share on other sites More sharing options...
JakeTheSnake3.0 Posted December 8, 2010 Share Posted December 8, 2010 To be honest, looking at the site I still don't know what you're trying to do. I only see one image (of a car) per item, even after selecting some of the dropdowns. In any case, whenever you are in a loop and you want to do something at every X (where X is a digit), use the modulo. if ($myVar % 2 == 0) // run every other time if ($myVar % 3 == 0) // run every 3rd time $myVar in those instances would be a counter variable Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1144686 Share on other sites More sharing options...
BCAV_WEB Posted December 9, 2010 Author Share Posted December 9, 2010 if you go to www.bikescarsandvans.co.uk/details.php you'll see what is wanted, that is currently done by manual inputting of all the data and I'm trying to get it to all come from a backend database for obvious reason. Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1144864 Share on other sites More sharing options...
BCAV_WEB Posted December 9, 2010 Author Share Posted December 9, 2010 Just realised that if I have even number with the MySQL result, the CSS of it all looks okay. So would a work around be to have a bit of coding that counted the rows and if odd, stick in an extra blank bit of data? Also on the manual inputted on (details.php) the coding has a <br/> after two; see example below, just ignore the $title_row["info"] etc... and imagine prices, text etc... *Also please note there is only the 1st Audi that has images in the additonal extras bit on the test.php page. <a class='data' href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $title_row["info"] . "<br/>(£" . $title_row["price"] . ")"; ?>");return false'> <?php print " <img class='extra_img' src=\"". $title_row["img"] ."\" alt='" . $title_row["img_alt"] . "' /></a> <a class='data' href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $title_row["info"] . "<br/>(£" . $title_row["price"] . ")"; ?>");return false'> <?php print " <img class='extra_img' src=\"". $title_row["img"] ."\" alt='" . $title_row["img_alt"] . "' /></a><br/> <a class='data' href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $title_row["info"] . "<br/>(£" . $title_row["price"] . ")"; ?>");return false'> <?php print " <img class='extra_img' src=\"". $title_row["img"] ."\" alt='" . $title_row["img_alt"] . "' /></a> <a class='data' href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $title_row["info"] . "<br/>(£" . $title_row["price"] . ")"; ?>");return false'> <?php print " <img class='extra_img' src=\"". $title_row["img"] ."\" alt='" . $title_row["img_alt"] . "' /></a><br/> Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1144882 Share on other sites More sharing options...
JakeTheSnake3.0 Posted December 9, 2010 Share Posted December 9, 2010 Open the attachment to see what I see. I only see one product (and product image) per line. I still don't know what you mean when you say you want two images before the break. The code I gave you should have been enough to do what you intend (insert a <br /> element every X times). All you needed to do was use a counter variable. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1144944 Share on other sites More sharing options...
BCAV_WEB Posted December 14, 2010 Author Share Posted December 14, 2010 I've just downloaded and looked at the image you've attached and you don't seem to go on the correct bit. The grey bar that says "Additional Extras" drops down and in there are images, such as walnut wood interior etc... If I limit it to one per line the drop down box goes stupidly to long, if a car has say 20 additional extras. Ps. Sorry for the late repoly I've had a few days off from work Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1147107 Share on other sites More sharing options...
BCAV_WEB Posted December 16, 2010 Author Share Posted December 16, 2010 Done, it Ive just had to play about with the CSS, setting a width and reducing padding and loads of junk like that but sorted now. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/221029-positioning-limiting-to-two-data-rows-per-line/#findComment-1148057 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.