php分页在本地主机上工作,但在服务器上不工作

时间:2019-07-14 05:39:37

标签: php sql pagination

大家好,我已经写了分页代码,该代码在localhost上是正确的,但是当我将其上传到服务器上时,它不起作用,只是显示“无产品”,因为我在其他条件下写它请帮助我解决此问题,因为此页面上的所有操作都正常,只是没有显示产品。

     <?php
        include "database.php";
        $id=$_GET['category_id'];
        $res= mysqli_query($link, "SELECT * from product where category_id= '$id' ORDER BY product_id DESC  ;");

         $result_per_page = 5;

          $number_of_result = mysqli_num_rows($res);
          $number_of_pages = ceil($number_of_result/$result_per_page);

         if(!isset($_GET['page'])){

           $page = 1;

                                }
               else{

                    $page = $_GET['page'];
                                }

         $this_page_first_result = ($page-1)*$result_per_page;

         $sql = "SELECT * FROM PRODUCT where category_id= '$id' LIMIT ".$this_page_first_result .','. $result_per_page;    
                            $result = mysqli_query($link, $sql);

          if(mysqli_num_rows($result)> 0){

             while($row=mysqli_fetch_array($result)){
                                ?>
          <div class="col-md-3 col-xs-6" >

        <a href="product.php?product_id=<?php echo $row["product_id"]; ?>" ><div class="product" style=" height: 426px;">   
        <div class="product-img">
                                                <img src="admin/<?php echo $row["product_image"]; ?>" alt="" style="height:200px;">
                                                <div class="product-label">
                                                                                            </div>
                    </div>
                    <div class="product-body">
                                                <p class="product-category"><?php echo $row["category_id"]; ?></p>


                                                                            <div >
                                                    <h3 class="product-name" ><?php echo $row["brand"]; ?></h3>
                                                </div>




                                                <h3 class="product-name"><a href="product.php?product_id=<?php echo $row["product_id"]; ?>"><?php echo $row["product_name"]; ?></a></h3>


                                                    <?php
         if($row["product_price"] < $row["ali_price"] && $row["product_price"] < $row["amazon_price"]){

          ?>

                                                <h4 class="product-price">$<?php echo $row["product_price"]; ?> </h4>
        <?php
           }
        else if ($row["ali_price"] < $row["product_price"] && $row["ali_price"] < $row["amazon_price"]) {
                     ?>            

                     <h4 class="product-price">$<?php echo $row["ali_price"]; ?> </h4>


                                      <?php      

                                                  }


                                                  else if  ($row["amazon_price"] < $row["product_price"] && $row["amazon_price"] < $row["ali_price"]){
                                                   ?>


        <h4 class="product-price">$<?php echo $row["amazon_price"]; ?> </h4>



          <?php

                   }
        ?>  
        </div>
        </div>  </a>
        </div>  
            <?php
                        }    
                        }

                                              else{
           echo "<h1><center>No Product Available!</center></h1>";

                                ?>
                   <?php


                   }
                         ?>




    <div class="store-filter clearfix">
    <ul class="store-pagination">
    <?php
    for($page=1 ; $page<=$number_of_pages; $page++){

    echo '<li><a href="store.php?category_id='.$id.'&page='.$page.'">'.$page. '</a></li>';
    ?>
    </ul>
    </div><!-- /store bottom filter -->

我希望输出将显示所有具有相关类别的产品。

0 个答案:

没有答案