在分页

时间:2015-10-16 05:15:07

标签: php mysql

我的分页href链接有问题。这是我目前的php文件。

<?php

      $query = $_GET["q"];

      $s= mysqli_query($connection,$query);
      $page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
      if ($page <= 0) $page = 1;

      $per_page = 10; // Set how many records do you want to display per page.

      $startpoint = ($page * $per_page) - $per_page;


      $querylimited = $query . " LIMIT {$startpoint} , {$per_page}";
      $_SESSION["query"] = $query;


      if(!empty($_POST))
      {
      $result = mysqli_query($connection,$querylimited);
      }
      else
      {

      $page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
      if ($page <= 0) $page = 1;

      $per_page = 10; // Set how many records do you want to display per page.

      $startpoint = ($page * $per_page) - $per_page;

      $s= mysqli_query($connection,$_SESSION["query"]);
      $querylimited = $_SESSION["query"] . " LIMIT {$startpoint} , {$per_page}"; 
      $result = mysqli_query($connection,$querylimited);  
      }

?>

<body>

<div class="container">
  <div class="page">
    <div class="content-area">

       <div class="col-group">
        <div class="col-6" style="width:1024px;overflow: auto;">
          <table width="100%" border="0">
            <tr>

              <td style="width:5%"><strong>Ref. #</strong></td>
              <td style="width:15%"><strong>Client Name</strong></td>
              <td style="width:10%"><strong>Contact</strong></td>
              <td style="width:5%"><strong>Con Type</strong></td>
              <td style="width:5%"><strong>Client Type</strong></td>
              <td style="width:10%"><strong>Date</strong></td>
            </tr>
            <?php while($rows = mysqli_fetch_array($result)): ?>

            <tr>
              <td><?php echo $rows['id']; ?></td>
              <td><?php echo $rows['clientname']; ?></td>
              <td><?php echo $rows['contact']; ?></td>    
              <td><?php echo $rows['contype']; ?></td>
              <td><?php echo $rows['clienttype']; ?></td>
              <td><?php echo $rows['l_date']; ?></td>
            </tr>

            <?php endwhile; ?>

          </table>



         <input type="button" onclick="window.close()" value="Close"/>

          <?php 
                if(!empty($_POST))
                {
                echo pagination($query,$per_page,$page,$url='?');  
                }
                 else {

                 echo pagination($_SESSION["query"],$per_page,$page,$url="'" . htmlspecialchars($_GET['q'], ENT_QUOTES) . "'");  

                 }


                ?>


        </div>
      </div>
    </div>
  </div>
</body>

这是$_GET('p')

select * from clients where clienttype='owner'

echo pagination($_SESSION["query"],$per_page,$page,$url="'" . htmlspecialchars($_GET['q'], ENT_QUOTES) . "'");

现在问题是,当我点击第2页链接时,它不会添加&page=2

0 个答案:

没有答案