简体   繁体   中英

Assign SQL rows unique pages

sorry if this is a bit vague although I really don't know how to explain this one.

Basically I already have a listing page that lists all of the rows in my database into a html template that lists each row into an eCommerce style category page using PHP.

I am using this code for the listing page using PDO:

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

Now what I want to do is create a page for each of the SQL rows however I am unsure how I can do this, just like an eBay product page really.

My main question is what method could I do to create individual pages that are dedicated to each SQL row?

If anyone could shed a bit of light on this for me it would be much appreciated.

Knowing you can extract data from a page to another using $_POST['name-of-your-element'] , I would say to do something like this :

  1. Creating a php page dedicated to display information of one specific row
  2. Putting some $_POST['...'] call to display the exact data

To do this, instead of just displaying your row in your actual page, you should create form for each row, and then adding a submit button for each row which will launch the "display row page" with the correct information. I would see something like this for each row :

<form method = "post" action = "displayData_Make.php">
    <div id = "Make" name = "Make">
        Make : <?php echo $row['Make'] ?>
    </div>
    <input type = "submit" value = "more information..." />
</form>

Then in you "displayData_Make.php" receive your information and display them like you want :

<?php 
    $info = $_POST['Make'];

    // Do what you want with this data
    // Display, etc...
?>

<!-- 
    Some html code
-->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM