Hi All,
I'm struggling with pagination in PHP with MS Access database. Below is the code I'm using to generate the pages but it is not giving the result as expected. instead of displaying 5 result per page it is displaying all the results on the same page. If I click on next page link than also it display the same result.
it is also giving me error
Notice: Undefined property: stdClass::$increm in C:\wamp\www\DLP\test\abc.php on line 43
<?php include("connect.php"); ?>
<?php
/******************************************************************************/
$limit = 5;
$query_count = "SELECT Count(*) AS [value]
FROM arichivedlog
WHERE (((arichivedlog.Activity)='HTTP'))";
$result_count = odbc_exec($conn, $query_count);
$totalrows = odbc_fetch_object($result_count);
if(empty($page)){ // Checks if the $page variable is empty (not set)
$page = 1; // If it is empty, we're on page 1
}
$limitvalue = $page * $limit - ($limit);
$limitnew = $limitvalue + $limit;
$query = "SELECT Date
FROM arichivedlog
WHERE Activity='HTTP'";
$result = odbc_exec($conn, $query);
while (odbc_fetch_array($result)) {
$test1 = odbc_result($result, 'Date');
echo $test1."<br>";
}
if($page != 1){
$pageprev = $page -1;
echo(" <b><a href='?page=$pageprev'>PREV</a></b> ");
}else{
echo(" PREV ");
}
$numofpages = $totalrows->value / $limit;
for($i = 1; $i <= $numofpages; ++$i){
if($i == $page){
echo(" [$i] ");
}else{
echo(" <b><a href='?page=$i'>$i</a></b> ");
}
}
if(($totalrows->increm % $limit) != 0){
if($i == $page){
echo(" [$i] ");
}else{
echo(" <b><a href='?page=$i'>$i</a></b> ");
}
}
if(($totalrows->value - ($limit * $page)) > 0){
$pagenext = $page +1;
echo(" <b><a href='?page=$pagenext'>NEXT</a></b> ");
}else{
echo(" NEXT ");
}
odbc_free_result($result);
?>