Jump to content

Recommended Posts

Hey guys, I am just wondering what method is used to give my PHP loop lists there own page based on the same template for each one.

 

A perfect example of this is eBay, if you look at the listing pages they then link to the actual product pages. I am just wondering how I can do this?

 

Here is my code setup:

<?php while($row = $results->fetch(PDO::FETCH_ASSOC))
 {
      echo '
   <div class="listing-container">
     <h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3>
     <h3 class="price-listing">£'.number_format($row['Price']).'</h3>
   </div>
   <div class="listing-container-spec">
<img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/>
 <div class="ul-listing-container">
   <ul class="overwrite-btstrp-ul">
     <li class="diesel-svg list-svg">'.$row["FuelType"].'</li>
     <li class="saloon-svg list-svg">'.$row["Bodytype"].'</li>
     <li class="gear-svg list-svg">'.$row["Transmission"].'</li>
     <li class="color-svg list-svg">'.$row["Colour"].'</li>
   </ul>
 </div>
 <ul class="overwrite-btstrp-ul other-specs-ul h4-style">
   <li>Mileage: '.number_format($row["Mileage"]).'</li>
   <li>Engine size: '.$row["EngineSize"].'cc</li>
 </ul>
 <button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked 
 </button>
 <button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details 
 </button>
 <button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive 
 </button>
 <h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4>
   </div>
     ';
      } ?>
 </div>

So as you can see I am using PDO to fetch this data from my database and sort the results to list every row of the SQL table into the HTML template I have made and is then looped.

 

My question is how can I give each row in my SQL table it's own page just like the eBay example I mentioned?

 

Does anyone know of any useful tutorials to achieve this or any examples of how this is done?

 

Thanks

 

I'm a little confused.  I don't see any PDO, and your script seems to be unrelated to your questions.

 

Normally, you would create a list with a bunch of links.  Each link would be something like <a href="index.php?task=getItem&id=123 />Item 123</a>.  Your server would then implement the getItem task and use the ID to create the page.

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.