Page 1 of 2 12 LastLast
Results 1 to 15 of 16

 

Thread: PHP - Pagination

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts


    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

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    forgot to mention ..

    its adding teh correct num of products .. just a problem with prev & next

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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); 

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

  5. #5
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ?

  6. #6
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  7. #7
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  8. #8
    Driving to win

    Status
    Offline
    Join Date
    Aug 2003
    Location
    If I'm not at home, I'm in hospital
    Posts
    7,370
    Thanks
    7
    Thanked 16 Times in 11 Posts
    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.

  9. #9
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    did nothing ...
    still same as before

  10. #10
    Driving to win

    Status
    Offline
    Join Date
    Aug 2003
    Location
    If I'm not at home, I'm in hospital
    Posts
    7,370
    Thanks
    7
    Thanked 16 Times in 11 Posts
    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.

  11. #11
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Totalrows = 1
    Page =

    appreciate the help . i just wanna pull my hair out at the mo

  12. #12
    Driving to win

    Status
    Offline
    Join Date
    Aug 2003
    Location
    If I'm not at home, I'm in hospital
    Posts
    7,370
    Thanks
    7
    Thanked 16 Times in 11 Posts
    when you call the page are you putting
    Code:
    http://www.yourdomain.co.uk/thispage.php?page=2
    The ? is significant.

    Also can you change line 8 to say

    Code:
    $totalrows = mysql_num_rows($cdoresult);
    And then see what it outputs for page and totalrows
    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.

  13. #13
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes & line is 8 is already $cdoresult

    really confusing me this one is lol

  14. #14
    Driving to win

    Status
    Offline
    Join Date
    Aug 2003
    Location
    If I'm not at home, I'm in hospital
    Posts
    7,370
    Thanks
    7
    Thanked 16 Times in 11 Posts
    Do you want to email me the whole page to info @ findmethebestprice.co.uk so I can look at the whole code, might give me a clue whats going on.
    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.

  15. #15
    Registered User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    581
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok cheers

    email on way now

Page 1 of 2 12 LastLast


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP Pagination problem
    By zinc in forum Programming
    Replies: 3
    Last Post: 25-10-06, 12:51 PM
  2. PHP Pagination Problem
    By Brett in forum Programming
    Replies: 4
    Last Post: 26-11-05, 09:53 PM
  3. Anyone anygood with xml, php, mysql and Affiliate Window
    By AnnonnyMouse in forum Affiliate Marketing Lounge
    Replies: 1
    Last Post: 23-09-04, 11:00 AM
  4. PHP or Browser Timeout?
    By Barry in forum Programming
    Replies: 6
    Last Post: 28-04-04, 01:04 PM
  5. PHP Pagination
    By MorleyM in forum Programming
    Replies: 5
    Last Post: 11-08-03, 08:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2