Jump to content

Archived

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

jomaro

Paging MySQL database results

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\" /]

Share this post


Link to post
Share on other sites
Take a look at:

[a href=\"http://www.php-mysql-tutorial.com/php-mysql-paging.php\" target=\"_blank\"]http://www.php-mysql-tutorial.com/php-mysql-paging.php[/a]

This will get you started and you can continue from there

Share this post


Link to post
Share on other sites

×

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.