Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 15-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  PHP - Pagination

Damn im absolutely shattered ...
less than 4 hours sleep in last 2 days

can anyone see what ive messed up here because my body and mind seems to have given up ..

PHP Code:
$limit 2;
mysql_select_db($dbn$dbc);
$cquery "SELECT count(*) from datafeed";
$cdoresult mysql_query($cquery$dbc);
$cresult mysql_fetch_assoc($cdoresult);
$totalrows mysql_num_rows($cresult);
if(empty(
$page)){    // Checks if the $page variable is empty (not set) 
        
$page 1;      // If it is empty, we're on page 1 
    

    
$limitvalue $page $limit - ($limit);  
    
// Ex: (2 * 25) - 25 = 25 <- data starts at 25 
     
$query  "SELECT * from datafeed WHERE type='Divan Bed' LIMIT $limitvalue, $limit";
$doresult mysql_query($query$dbc);
$result mysql_fetch_assoc(doresult);
?> 
Recordset Nav
PHP Code:
 <?php if($page != 1){  
        
$pageprev $page--;        
        echo(
"<a href=\"divan-beds.php?page=$pageprev\">PREV".$limit."</a> ");   
    }else 
        echo(
"PREV".$limit." ");  
        
// If we're on page 1, PREV is not a link 
   
if(($totalrows - ($limit $page)) > 0){ 
        
        
$pagenext   $page++; 
            
        echo(
"<a href=\"divan-beds.php?page=$pagenext\">NEXT".$limit."</a>"); 
      
    }else{ 
        echo(
"NEXT".$limit);  

    } 

?>
any help appreciated.. really need my sleep
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 15-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

forgot to mention ..

its adding teh correct num of products .. just a problem with prev & next
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 15-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

also getting
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\kingsizebeds\divan-beds.php on line 8

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\kingsizebeds\divan-beds.php on line 18

PHP Code:
$limit 6;
mysql_select_db($dbn$dbc);
$cquery "SELECT count(*) from datafeed";
$cdoresult mysql_query($cquery$dbc);
$cresult mysql_fetch_assoc($cdoresult);
LINE 8 ->   $totalrows mysql_num_rows($cresult);
if(empty(
$page)){    // Checks if the $page variable is empty (not set) 
        
$page 1;      // If it is empty, we're on page 1 
    


    
$limitvalue $page $limit - ($limit);  
    
// Ex: (2 * 25) - 25 = 25 <- data starts at 25 
     
$query  "SELECT * from datafeed WHERE type='Divan Bed' LIMIT $limitvalue, $limit";
$doresult mysql_query($query$dbc);
LINE 18 -> $result mysql_fetch_assoc(doresult); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 15-11-07
MoonBug's Avatar
Registered User
 
Join Date: Apr 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
MoonBug is an unknown quantity at this point
  Re: PHP - Pagination

Quick scan says to me 'SELECT count' query wont return rows but the number of records in your table, or if it does perhaps this will be 1?

Also Line 18 is missing a '$' -> mysql_fetch_assoc($doresult)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 16-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

fixed the $ error but still nothing..

returning products but if i set limit to 2
it will only display 2 products and teh URLs for prev & next are inactive

any one any ideas ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 16-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

and also if i add page=2 or page=3 etc to the url in teh address bar it only returns the same results as it does without $page being set
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 16-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

also so people know where i got this code.. it was from here
PHP Help: Pagination: Easy as PREV 1 2 3 NEXT

ive ammeded it to match my db but everything else is teh same so dont see teh problem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #8 (permalink)  
Old 16-11-07
drivetowin's Avatar
Driving to win
 
Join Date: Aug 2003
Location: If I'm not at home, I'm in hospital
Posts: 7,364
Thanks: 5
Thanked 8 Times in 5 Posts
drivetowin seems to know their stuff
  Re: PHP - Pagination

try adding
Code:
$page=$_GET['page'];
to the start of your code and then putting page=2, page=3 etc after your url.
__________________
Never argue with idiots. They just drag you down to their level and then beat you with their experience.

If ignorance is bliss then some of the people I know must be orgasmic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 16-11-07
Registered User
 
Join Date: Sep 2007
Posts: 582
Thanks: 0
Thanked 0 Times in 0 Posts
cyates is an unknown quantity at this point
  Re: PHP - Pagination

did nothing ...
still same as before
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 16-11-07
drivetowin's Avatar
Driving to win
 
Join Date: Aug 2003
Location: If I'm not at home, I'm in hospital
Posts: 7,364
Thanks: 5
Thanked 8 Times in 5 Posts
drivetowin seems to know their stuff
  Re: PHP - Pagination

can you put in a couple of lines after line 8

Code:
echo ("Totalrows = " . $totalrows);
echo ("Page = " . $page);
and see what they output.
__________________
Never argue with idiots. They just drag you down to their level and then beat you with their experience.

If ignorance is bliss then some of the people I know must be orgasmic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #11 (permalink)