分配SQL行唯一页面

时间:2014-09-20 18:45:38

标签: php mysql sql pdo

抱歉,如果这有点模糊,虽然我真的不知道如何解释这个。

基本上我已经有了一个列表页面,它将我数据库中的所有行列为一个html模板,该模板使用PHP将每一行列入电子商务风格类别页面。

我在使用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> 

现在我要做的是为每个SQL行创建一个页面,但我不确定如何做到这一点,就像eBay产品页面一样。

我的主要问题是我可以用什么方法创建专用于每个SQL行的单个页面?

如果有人能为我揭开这一点,我将不胜感激。

1 个答案:

答案 0 :(得分:0)

知道你可以使用$_POST['name-of-your-element']从一个页面提取数据到另一个页面,我会说这样做:

  1. 创建专门用于显示特定行信息的php页面
  2. 进行一些$ _POST [&#39; ...&#39;]调用以显示确切的数据
  3. 要执行此操作,您应该为每一行创建表单,然后为每一行添加一个提交按钮,而不是仅在实际页面中显示您的行,而不是在每行中添加一个提交按钮,这将显示&#34;显示行页面&#34;有正确的信息。我会在每一行看到类似的东西:

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

    然后在你&#34; displayData_Make.php&#34;收到您的信息并按您的要求显示:

    <?php 
        $info = $_POST['Make'];
    
        // Do what you want with this data
        // Display, etc...
    ?>
    
    <!-- 
        Some html code
    -->
    
相关问题