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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.