Limiting Records
Posted: Tue Mar 17, 2009 12:07 pm
This code limits records to 12 records per page. Can anyone tell me how to control the number of records per page?
I don't see anywhere where the limit is set to 12... Not sure what I am missing.
Thanks
I don't see anywhere where the limit is set to 12... Not sure what I am missing.
Thanks
Code: Select all
<?
class newsSql{
function getNews($perPage='0',$onPage='0',$where='')
{
global $DB,$AUTH;
$sqlstart = ($perPage * $onPage) - ($perPage);
$sqlstop= $perPage;
$limit = ($sqlstart == 0 && $sqlstop == 0 ) ? '' : " LIMIT ".$sqlstart.",".$sqlstop;
$sql="SELECT SQL_CALC_FOUND_ROWS * from GTM_NEWS ";
$sql .= ($where != "") ? $where : '';
$sql .=" ORDER by date_entered DESC " ;
$sql .= $limit;
$res = $DB->run_query($sql);
//print_r($DB);
if($res && $res->num_rows > 0 )
{
//print_r($res);
$pgs = $DB->getTotalPages($perPage);
$res->total_num_items = $pgs['totalItems'];
$res->total_pages = $pgs['totalPages'];
return $res;
}
return false;
}
function getArticle($id)
{
global $DB;
if( ! is_numeric($id) ) return false;
$res = $DB->run_query("SELECT * FROM GTM_NEWS WHERE news_id='".$id."'");
if($res && $res->num_rows == 1)
{
//print_r($res);
return $res->row;
}
else
{
return false;
}
}
}// end class
?>