Jump to content


Photo

Paging MySQL database results


  • Please log in to reply
1 reply to this topic

#1 jomaro

jomaro
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 23 June 2006 - 09:20 AM

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:


$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();

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

#2 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 23 June 2006 - 01:30 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users