Search Multiple Record through dates with Pagination in php and display 5 records per page

<table>

     //Table Heading

<tr>
<th class=”th-bgc”>ID</th>
<th class=”th-bgc”>First name</th>
<th class=”th-bgc”>Last name</th>
<th class=”th-bgc”>Course</th>
<th class=”th-bgc”>Date Of Registration</th>
<th class=”th-bgc”>Total amount</th>
<th class=”th-bgc”>Deposit amount</th>
<th class=”th-bgc”>Details</th>
</tr>
if(isset($_POST[‘search’]))
{
$dfrom = $_POST[“from”];   //date form
$dto = $_POST[“to”];        //date to
$page = $_GET[“page”];   // page no. passes through URL.
if($page == “” || $page == “1”)
{
$page1 = 0;
}
else
{
$page1 = ($page*5)-5;
}
$query =(“select Id,FirstName, LastName,AirCourse, DefensiveCourse,DOR,TPayment,deamount from users where DOR Between ‘”.$dfrom.”‘ and ‘”.$dto.”‘  limit $page1,5″);  //sql query
$qu= mysql_query($query, $con);
if($qu>= 1)
{

echo “Searching Successfully”;
}
}
while($res1=mysql_fetch_array($qu))
{
// search record in table
<tr>
<td><input type=’checkbox’ id=”id” name=’id’ value= <!–?php echo $res1[‘Id’]; ?>  />    //checkbox  use id check or not
<td><?php echo $res1[‘FirstName’];?>
<td><?php echo $res1[‘LastName’];?>
<td><?php echo $res1[‘AirCourse’];?>

<td><?php echo $res1[‘DOR’];?>
<td><?php echo $res1[‘TPayment’];?>
<td><?php echo $res1[‘deamount’];?>

<?php $eid  = $res1[‘Id’];?>
<td><a href=”detail.php?id=<!–?php  echo $eid; ?>”> Details
</td>  URL through pass id one page to another page
</tr>
}
if(isset($_POST[‘dsearch’]))
{
$query1=(“select Id,FirstName, LastName,AirCourse, DefensiveCourse,DOR,TPayment,deamount from users where DOR Between ‘”.$dfrom.”‘ and ‘”.$dto.”‘  limit $page1,5″) or exit(mysql_error());  ///pagination query
$qu1 = mysql_query( $query1, $con);
$count =  mysql_num_rows($qu1);
$a = $count/5;   //count variable count row in data table
$a = ceil($a);
echo “<br>”; echo “<br>”;
}

</table>
<table width=”100%” border=”0″ style=”height:50px”>  //page no. table
<tr>
<td style=”text-align:right;vertical-align:top;”>

for($b=1; $b<=$a; $b++)
{
<a href=”searchdor.php?page=” style=”text-decoration:none”>    //pagination loop
}

</td>
</tr>
</table>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s