I am trying to do something like when you press next button in my php file it will give you next record from database and display it. So I have the solution which is following:
$next_id = q("select * from sites where id > ".$siteid.
" and com_id = ".$current_company_id." and deleted = 0 order by id ASC LIMIT 1");
//print_r($next_id);
$tot_id = getNumberRows($next_id);
if($tot_id){
while($next_site = $next_id->fetch(PDO::FETCH_ASSOC)) {
$next_site_id = $next_site['id'];
//echo $next_site['id'];
}
} else {
$next_site_id = 0;
}
if($next_site_id == 0) {
//don't give button any more as last record......
} else {
//echo $next_site_id;
?>
<div class="pull-right" style="margin-left:10px !important;">
<a href="sites.php?id=<?php echo $next_site_id; ?>">
<button class="btn btn-info btn-s">Next</button>
</a>
</div>
<?php
}?>
Above solution is display one by one record and when there is no record next button will not display but everything is working so fine but somehow when it's reach to 10th record or 12 record or any number of record and then I press next it move to 1st record. So crazy I don't know what the hell is happening there.
So if anyone have better solution to this.?