我想知道如何使用分页进行多次搜索

时间:2015-05-21 06:21:00

标签: php

我想知道如何使用分页进行多次搜索。看到总数我给了200条记录。每个页面我需要显示20条记录。我希望输出像这样:

  1. 显示总共200条记录中的1到2个,其次是第二页
  2. 应显示200的21至40。
  3. 这是我第一次使用分页进行多次搜索。到目前为止我所做的是,我在这里给出了。

    以下是表格:

    <form name="f1" action="" method="post">
    <input type="text" name="pincode"     id="zipsearch"  value='<?php echo $pincode;?>'  class="buttonlengths" placeholder="Search By pincode,Area,State" required/><br/><br/>
    <select name="categorypincode" ize="40" class="buttonlengths" />
    <option value="">select the subject</option>
    <option value="Class I-V Tuition" <?php  if($categorypincode=='Class I-V Tuition') { echo 'selected'; }?>>Class I-V Tuition</option>
    <option value="Class VI-VIII Tuition" <?php  if($categorypincode=='Class VI-VIII Tuition') { echo 'selected'; }?>>Class VI-VIII Tuition</option>
    <option value="Class IX-X Tuition">Class IX-X Tuition</option>
    <option value="Class XI-XII Tuition">Class XI-XII Tuition</option>
    </select><br/><br/>
    <input type="text" name="tutorname" value="<?php echo $tutorname; ?>" class="buttonlengths" placeholder="Search By Tutor Name"/><br/><br/>
    <input type="submit" id="tbx2"  name="submitpincode" value="Search"/>
    </form>
    
    
    <?php
         $pincode=$_POST['pincode'];
         $categorypincode=$_POST['categorypincode'];
         $tutorname=$_POST['tutorname'];
         if($pincode!='' &&  $categorypincode!='' &&  $tutorname!='')
        {
        $sql=mysql_query("SELECT  tr.*, t.*  FROM  tinfo  t left join tutorregistration tr  on  tr. tid=t.tsid where pincode LIKE '%$pincode%' and classconducted LIKE '%$categorypincode%' and name LIKE '%$tutorname%'");
        }
        else if($pincode!='' &&  $categorypincode!='' )
        {
        $sql=mysql_query("SELECT  tr.*, t.*  FROM  tinfo  t left join tutorregistration tr  on  tr. tid=t.tsid where
        pincode LIKE '%$pincode%' and classconducted LIKE '%$categorypincode%'");
        }
        else if($pincode!='')
        {
        $sql=mysql_query("SELECT  tr.*, t.*  FROM  tinfo  t left join tutorregistration tr  on  tr. tid=t.tsid where
        pincode LIKE '%$pincode%'");
        }
    ?>
    
    
      <div class="middle_cnt">
        <?php
        if(isset($_POST['submitpincode']))
        {
        while($row=mysql_fetch_array($sql))
        {
        $v=$row['tinfoid'];
        ?>
        <div class="frst_middle">
        <div class="frst_mid_scd">
        <?php  
      echo  '<span class="details">Years of Experience:</span>'.$row['texper'];?><Br/><Br/>
        <?php echo  '<span class="details"> Expertise In:</span>'.$row['texperdetails'];?><Br/><Br/>
        <?php echo   '<span class="details">Teaching Segment.</span>'.$row['commonsegment'];?><br/><Br/>
        <span style="padding-left:300px;" class="details"><a href="tutordetail.php?tid=<?php echo $row['tinfoid'];?>" style="cursor:pointer;">View details</a></span>
        </div><!--end of frst_mid_scd-->
        </div><!--end of frst_middle-->
        <?php
        }
        }
        ?>
    

    我已经给出了我的数据库的结果一切正在为我工​​作只有问题是多重搜索和分页。

0 个答案:

没有答案