pagination for search page which consists of 5 different search fileds.&export

i want to do pagination for my search page results . here i am writing the code below
html code:

<form action="result.php" method="post">
<!--<table width="60%" padding="8px" id="tbl"> -->
<table width="60%" padding="8px" >
<tr>
<td><label><font style="font-size:20px">Run No:</font></label></td>
<td><input  type="text" name="run" id="run" placeholder="Eg:46A" size=32 style="font-size:18px"></td>
</tr>
<tr>
<td><label><font style="font-size:20px">Project Name:</font><label></td>
<td><input  type="text" name="project" id="project" placeholder="Eg:chickpea3000 genome" size=32 style="font-size:18px"></td>
</tr>
<tr>
<td><label><font style="font-size:20px">Sample Name:</font><label></td>
<td><input  type="text" name="sample" id="sample" placeholder="Eg:ICC2177" size=32 style="font-size:18px"></td>
</tr>
<tr>
<td><label><font style="font-size:20px">Bases:</font></label>
<!--<select style="font-size:18px" name="select" id="select" >
<option value="single" selected="selected">Single-End</option>
<option value="pair">Pair-End</option>
</select> -->
<select style="font-size:18px" name="select1" id="select1" >
<option value="greaterthan" selected="selected">&gt;</option>
<option value="greaterthanorequal">&ge;</option>
<option value="lessthan">&lt;</option>
<option value="lessthanorequal">&le;</option>
<option value="equal">&#38;#38;#x3d;</option>
</select>
</td>
<td><input  type="text" name="bases" id="bases" placeholder="Eg:10125918250" size=32 style="font-size:18px"></td>
</tr>
<tr>
<td><label><font style="font-size:20px">Reads:</font></label>
<!--<select style="font-size:18px" name="select3" id="select3" >
<option value="single" selected="selected">Single-End</option>
<option value="pair">Pair-End</option>
</select> -->
<select style="font-size:18px" name="select2" id="select2" >
<option value="greaterthan" selected="selected">&gt;</option>
<option value="greaterthanorequal">&ge;</option>
<option value="lessthan">&lt;</option>
<option value="lessthanorequal">&le;</option>
<option value="equal">&#38;#38;#x3d;</option>
</select>
</td>
<td><input  type="text" name="reads" id="reads" placeholder="Eg:81007346" size=32 style="font-size:18px"></td>
</tr>
<tr>
<td></td>
<td><input type="reset" class="reset" name ="reset" value="Reset" style="font-size:18px">
<input type="button" name="submit" value="Search"    style="font-size:18px"></td>
</tr>
</table>
</form>

here i am writing the php code to display results based on search criteria
[php]
if(isset($_POST[‘submit’]))
{
if(!empty($_POST[‘run’]))
{
$value1=$_POST[‘run’];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND c.id=a.id WHERE a.run like ‘%$value1%’ ";
}
else if(!empty($_POST[‘project’]))
{
$value1=$_POST[‘project’];
$sql=“SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND c.id=a.id WHERE a.project like ‘%$value1%’”;
}
else if(!empty($_POST[‘sample’]))
{
$value1=$_POST[‘sample’];

     //$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases,b.raw_reads,c.raw_bases2,c.raw_reads2 from cp_sampleSheet a inner JOIN cp_samp_R1 b ON b.sample_id = a.sample_id and a.run=b.run inner JOIN cp_samp_R2 c ON c.sample_id = a.sample_id and a.run=c.run WHERE a.sample_id like '%$value1%' group by a.run ";

$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a LEFT JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id LEFT JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE a.sample_id like '%$value1%' order by a.run ";
    }
    else if(!empty($_POST['bases']))
   {
     $values=$_POST['select1'];
     if($values=='greaterthan')
      {
       $value1=$_POST['bases'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) > '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc";
      } 
      else if($values=='greaterthanorequal')
      {
       $value1=$_POST['bases'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) >= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc "; 
      } 
      else if($values=='lessthan')
      {
      $value1=$_POST['bases'];
      $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) < '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc "; 
      }
      else if($values=='lessthanorequal')
      {
       $value1=$_POST['bases'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) <= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc ";
      }
      else if($values=='equal')
      {
       $value1=$_POST['bases'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) = '$value1' ";
      }
    }

    else if(!empty($_POST['reads']))
    {
     $values2=$_POST['select2'];
     if($values2=='greaterthan')
      {
       $value5=$_POST['reads'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) > '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
      }
      else if($values2=='greaterthanorequal')
      {
       $value5=$_POST['reads'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) >= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
      }
      else if($values2=='lessthan')
      {
       $value5=$_POST['reads'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) < '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
      }
      else if($values2=='lessthanorequal')
      {
       $value5=$_POST['reads'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) <= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
      }
      else if($values2=='equal')
      {
       $value5=$_POST['reads'];
       $sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id AND a.id=b.id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id AND a.id=c.id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) = '$value5' ";
      }
    }
 }

$counter=$start;

if( @$result = mysqli_query($link, $sql." LIMIT $start, $per_page " ) ) {
if(mysqli_num_rows($result) > 0) {
?>

<?php while($row = mysqli_fetch_array($result)){ ?>
           <tr>
           <td align="center"><?php echo ++$counter;?> </td> 		
           <td align="center"><?php echo $row['run'] ;?> </td>
           <td align="center"><?php echo $row['lane'] ;?> </td>
           <!-- <td><?php echo $row['sample_id'] ;?> </td> -->

           <td align="center"> <?php echo $row['sample_id']; ?></td>   
               
            <td align="center"><?php echo $row['end_type'] ;?> </td>
           <td align="center"><?php echo $row['project'] ;?> </td>

            <td align="center"><?php  $a=(($row['raw_bases'])+($row['raw_bases2'])); echo $a;?> </td>
             <td align="center"><?php  $a=(($row['raw_bases'])+($row['raw_bases2']))/1000000000; $var = floor($a*100)/100; echo $var;?> </td>
              <td align="center"><?php  $b=(($row['raw_reads'])+($row['raw_reads2'])); echo $b;?> </td>
               <td align="center"><?php  $b=(($row['raw_reads'])+($row['raw_reads2']))/1000000; $var = floor($b*100)/100; echo $var;?> </td>
<?php } // Close result set // mysqli_free_result($result); } else{ echo " No records matching your query were found."; } } ?>

[/php]

code is working fine for display search results. i want the results to be in pagination and export option. plz anybody help me to sort out this.

Sno Run Lane Sample Name End Type Project Name Total Raw Bases Bases(In Gbp) Total Raw Reads Reads(In Mbp)

Whats up with the duplicate posts with different usernames?

https://www.phphelp.com/forum/general-php-help/pagination-for-search-page-which-consists-of-5-different-search-fileds-export/?topicseen

Sponsor our Newsletter | Privacy Policy | Terms of Service