页面

时间:2018-04-13 13:44:46

标签: php mysql database

这是我用来发布id的值并在下一页上重现该id的代码

<?php
              global $row6;
              $query= "select s.name ,s1.price from services s ,seller_services s1 where s1.service_id = s.id LIMIT 7;";
              $result= mysqli_query($conn3,$query) or die(mysqli_error($conn3));
              while($row6=mysqli_fetch_array($result))
              {
                ?>
              <div class="col-md-3 col-sm-4">
                <div class="pro-box">
                  <div class="pro-thumb"><img src="https://udemy-images.udemy.com/course/240x135/1192700_6496_2.jpg" alt=""></div>
                  <div class="pro-txt"> <a href="#" class="add2cart"><i class="fa fa-shopping-cart"></i></a>
                    <h6><a href=""><?php echo $row6['name'];?></a></h6>
                    <p class="price"><i class="fa fa-inr" aria-hidden="true"></i><?php echo $row6['price'];?></p>
                    <form action="manageservice.php" method="POST">
                       <button name="buy"><input type="submit" hidden="id" value="buy" name="buy"/></button>
                     </form>
                     <div class="pro-rating"><a href="#"><i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i></a></div>
                  </div>
                </div>
              </div>
              <?php } ?> 

这是我用来接收id的值的代码,但它没有显示任何我不知道的

<div class="team-page">
      <div class="container">
        <div class="row"> 
           <?php 
          global $row;
          if(isset($_POST['buy']))
                                    {
                                        $id=$_POST['id'];
          $query5= "Select *from services where id = '$id'; ";
          $result=mysqli_query($conn3,$query5) or die("Mysql error");

           while($row=mysqli_fetch_array($result))
                                        {
                                          ?>

          <!--Team Box Start-->
          <div class="col-md-3 col-sm-6">
            <div class="team-box">
              <div class="thumb">
                <div class="team-hover">
                  <h6>Michelle WU</h6>
                  <p>Aliquam nec finibus dui, eget dapibus leo. Suspendisse aliquam, justo in venenatis congue, sem odio vestibulum lorem, quis consectetur arcu nulla in est. </p>
                  <div class="mayor-social"> <a class="fb" href="#"><i class="fa fa-facebook"></i></a> <a class="tw" href="#"><i class="fa fa-twitter"></i></a> <a class="lin" href="#"><i class="fa fa-linkedin"></i></a> <a class="yt" href="#"><i class="fa fa-youtube"></i></a> </div>
                </div>
                <img src="images/timg-1.jpg" alt=""></div>
              <div class="team-txt">
                <h5><?php  echo $row['name'];?></h5>
                <p><?php  echo $row['email'];?></p>
              </div>
            </div>

            <div class="loc-footer" style="background-color:#fff;">
                <ul>
                  <li class="loc-rating">4.98 <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star"></i> <i class="fa fa-star-half-o"></i></li>
                  <li class="more">
                    <div class="btn-group dropup">
                      <button type="button" data-toggle="dropdown"> <i class="fa fa-ellipsis-h"></i> </button>
                      <ul class="dropdown-menu">
                        <li><a href="#"><i class="fa fa-envelope-o"></i> Send Email</a></li>
                        <li><a href="#"><i class="fa fa-commenting-o"></i> Send Message</a></li>
                        <li><a href="#"><i class="fa fa-compass"></i>Request a Call Back</a></li>
                      </ul>
                    </div>
                  </li>
                </ul>
              </div>
          </div>
          <?php } ?>
          <?php } ?>

所以现在的问题是,id不会收到任何价值或者我无法弄清楚该怎么做的事情请帮助人们

1 个答案:

答案 0 :(得分:0)

根据我以前的不完整答案:我认为您的问题是您尝试显示$row的值,但是在while($row=mysqli_fetch_array($result))循环之外。我试图修复你的代码。尝试一下,让我知道它是否正常工作,或者是否有任何错误。

<div class="team-page">
      <div class="container">
        <div class="row"> 
          <?php 
              global $row;
              if(isset($_POST['buy'])) {             
                  $id=$_POST['id'];
                  $query5= "Select *from services where id = '$id'; ";
                  $result=mysqli_query($conn3,$query5) or die("Mysql error");
             }
          ?>
          <!--Team Box Start-->
          <div class="col-md-3 col-sm-6">
            <div class="team-box">
              <div class="thumb">
                <div class="team-hover">
                  <h6>Michelle WU</h6>
                  <p>Aliquam nec finibus dui, eget dapibus leo. Suspendisse aliquam, justo in venenatis congue, sem odio vestibulum lorem, quis consectetur arcu nulla in est. </p>
                  <div class="mayor-social"> <a class="fb" href="#"><i class="fa fa-facebook"></i></a> <a class="tw" href="#"><i class="fa fa-twitter"></i></a> <a class="lin" href="#"><i class="fa fa-linkedin"></i></a> <a class="yt" href="#"><i class="fa fa-youtube"></i></a> </div>
                </div>
                <img src="images/timg-1.jpg" alt=""></div>
              <div class="team-txt">
              <?php
                  while($row=mysqli_fetch_array($result)) {
              ?>
                  <h5><?php  echo $row['name'];?></h5>
                  <p><?php  echo $row['email'];?></p>
               <?php } ?>

              </div>
            </div>