html – The problem of cannot pass ?= value in php pagination

Questions:

I have do a pagination with php&html,the problem is my $page is always equal 1 even I click another page and the url is already become ?page=2.The value $p cannot pass as $page.How can I solve this?

<ul class="nospace clear" style="width:1310px;">
      <?php
      if(isset($_GET['page'])&& $_GET['page']!=""){$page = $_GET["page"];}else{$page=1;}
      $current=$page;
      $end=12;
      if($page=1){$start=0;$previous=$page;$next=$page+1;}
      else if($page<=12){$start=$page*12-12;$previous=$page-1;$next=$page+1;}
      else{$start=0;$previous=$page-1;$next=12;}
      $sql = "Select * from item where Gender='women' AND Category='cloth' LIMIT $start,$end";
      $result = mysqli_query($connect,$sql);
      while($row=mysqli_fetch_assoc($result)){?>
      <a href="productdetail.php?detail&id=<?php echo $row["id"] ?>" ><li style="display:inline;float:left;width:21.8421%;clear:right;padding-left:30px;"><img src="../images/demo/<?php echo $row["Pic"]; ?>" style="width:300px;height:280px"><br><p></p><h3><strong><?php echo $row["Name"]; ?></strong></h3></a><p><?php echo $row["Description"]; ?></p></li>
      <?php } ?></ul><figcaption>Page <?php echo"$page ";?> end...</figcaption>
    </figure>
  </div>
  <nav class="pagination">
    <ul>
      <li><a href="?page=<?php echo $previous; ?>"class="btn1">&laquo; Previous</a></li>
      <?php 
        for ($p=1;$p<13;$p++){
        if ($page == $p) {?>
        <li class="current btn1"><strong><?php echo $p ?></strong></li><?php }
        else{?><li><a href="?page=<?php echo $p ?>" class='btn1'><?php echo $p ?></a></li><?php }}?>
        <li><a href="?page=<?php echo $next ?>" class="btn1">  Next &raquo; </a></li>
     </ul>
How to&Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *