Jump to content

Positioning / limiting to two data rows per line


BCAV_WEB

Recommended Posts

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>
								";	

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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/>

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

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.