Jump to content

Paging MySQL database results


jomaro

Recommended Posts

Hi,

I am not a programmer but i have good experience of programing, i have been studied but not working with programming.

I am sitting 2 days to sort the MySQL results with paging,, but i failed :(

This is my script:


[code]$where  = " AND (";
if ($sections != "") $where .= "sectionid IN (". $sections. ") ";
if ($sections != "" && $categories != "" ) $where .= " OR ";
if ($sections != "" && $categories != "" ) $where .= "cc.id IN (". $categories. ")";
$where .= ") ";

// query records
$query = "SELECT a.*, cc.image AS image"
    . "\n FROM #__content AS a"
    . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
    . "\n WHERE a.state = '1'"
    . $where
    . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now'  )"
    . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )"
    . "\n AND published = '1'"
    . "\n ORDER BY publish_up DESC";

$database->setQuery( $query );
$rows = $database->loadObjectList();
echo $database->getErrorMsg();[/code]

I just want to paging the results
For example like this:
[!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--]Page 1 of 4
Results 1 - 10 of 35[!--colorc--][/span][!--/colorc--]

Thanks [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
Link to comment
https://forums.phpfreaks.com/topic/12714-paging-mysql-database-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.