Page 1 of 1

Limiting Records Displayed

Posted: Mon Mar 16, 2009 3:50 pm
by dmgt
Hi All,

Newbie sifting through code by someone that is not around.

Right now the code displays 12 Records per page- All I want to do is change it to 6. I can't find out where control.

Thanks for any guidance

Mark

Code: Select all

 
<?
class newsFunctions{
 
function getNews($perPage='0',$onPage='0',$where='0')
{
 
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;
        }
 
 
 
}
 
function getNewsList($onPage,$perPage,$where='')
{
 
    global $OUT,$FNS;
    
    $queryRes = $this->getNews($perPage,$onPage,$where);
    $output = array();
    if($queryRes && $queryRes->num_rows > 0 )
    {
        foreach($queryRes->result as $row)
        {
            $row['mids'] = explode(',',$row['news_mapids']);
            $output[] = $row;
        }   
                $OUT->templateVars['newsList'] = $output;
                $OUT->templateVars['newsTotal']  = $queryRes->total_num_items;
                $OUT->templateVars['Paging'] =$FNS->getPaging($queryRes->total_pages,$onPage,$perPage);
    }
    else
        {
                $OUT->templateVars['no_query_results'] = true;
        }
 
}
 
 
}// end class
?>
<?
require_once('news_sql.php');
require_once(PATH_MODS.'maps/maps_data.php');
 
class getnews extends news_sql {
 
    var $NEWSSQL = '';
    var $perPage = '5';
 
function getnews()
{
// nothing
}
 
 
function getNewsList($where='')
{
 
    global $REQ,$OUT,$FNS;
    
    $onPage = (isset($REQ->urlArray['page']) && is_numeric($REQ->urlArray['page'])) ? $REQ->urlArray['page'] : 1;
    $queryRes = $this->NEWSSQL->getNews($this->perPage,$onPage,$where);
    $output = array();
    if($queryRes && $queryRes->num_rows > 0 )
    {
        foreach($queryRes->result as $row)
        {
            $row['mids'] = explode(',',$row['news_mapids']);
            $output[] = $row;
        }   
                $OUT->templateVars['newsList'] = $output;
                $OUT->templateVars['queryTotal']  = $queryRes->total_num_items;
                $OUT->templateVars['Paging'] =$FNS->getPaging($queryRes->total_pages,$onPage,$this->perPage);
    }
    else
        {
                $OUT->templateVars['no_query_results'] = true;
        }
 
}
 
function getArticle($id)
{
$data = $this->NEWSSQL->getArticle($id);
return $data;
 
}
 
}// end class
?>
 

Re: Limiting Records Displayed

Posted: Mon Mar 16, 2009 4:00 pm
by deejay
It'll be in the class call up.

can you post that up.

Re: Limiting Records Displayed

Posted: Mon Mar 16, 2009 4:20 pm
by gellnsh
Hi,

If you can find this on your page:

$limit = 12;

Just change it to this:

$limit = 6;

Re: Limiting Records Displayed

Posted: Mon Mar 16, 2009 4:35 pm
by dmgt
I wish it were that easy.

I search the entire site and can't find:

$limit = 12;

Any ideas?