hi
i am developing a website where i am using a pagination code .
i want to display the result of the candidate from table record_result on the basis of certain time period given by admin.
that is my code...
<?php
include 'mysql-connect.php';
// how many rows to show per page
$rowsPerPage = 4;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$order = "SELECT * FROM result_record WHERE ex_date>='$var' AND ex_date<='$var1'".
" LIMIT $offset, $rowsPerPage";
$result = mysql_query($order);
while($data = mysql_fetch_row($result))
{
echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[4]</td><td>$data[3]</td><td>$data[5]</td><td>$data[6]</td></tr>");
}
?>
<?php
$query1 = "SELECT COUNT(*) AS numrows FROM result_record";
$result1 = mysql_query($query1) or die('Error, query failed');
$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
$numrows = $row1['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
// ... still more code coming
?>
<?php
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
echo $first . $prev .
" Showing page $pageNum of $maxPage pages " . $next . $last;
?>
the problem is it is not give the desired output.
plz any one help me that what is the problem????
or how to use limit with where clause...