10 records per page?

Discussion in 'PHP' started by gilgalbiblewheel, Nov 26, 2007.

  1. #1
    How does PHP display 10 records per page?
     
    gilgalbiblewheel, Nov 26, 2007 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    if u mean that the info displayd come from a database then it will be using sql query and adding the "LIMIT 10" to the query

    if from a text based ... just by using a simple if and maybe a variable $i that will count ..
     
    commandos, Nov 26, 2007 IP
  3. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Like this?

     
    gilgalbiblewheel, Nov 26, 2007 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    if ur query is correct yes the limit will only return 10 if u add LIMIT 10 ...
     
    commandos, Nov 26, 2007 IP
  5. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    It's not working:
     
    gilgalbiblewheel, Nov 26, 2007 IP
  6. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #6
    I made some editing but still getting error.

     
    gilgalbiblewheel, Nov 27, 2007 IP
  7. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Limit 0,10 is use only for mysql not for SQL Server
     
    salmanshafiq, Nov 27, 2007 IP
  8. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #8
    So any other way? I've been waiting for an answer for two days now.
     
    gilgalbiblewheel, Nov 28, 2007 IP
  9. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
  10. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    SELECT * FROM `your_table` LIMIT 0, 10
     
    vonvhen, Nov 28, 2007 IP
  11. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #11
    there is no "LIMIT" In SQL server .
     
    commandos, Nov 28, 2007 IP
  12. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    PHP with SQL server?
     
    vonvhen, Nov 28, 2007 IP
  13. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #13
    gilgalbiblewheel, Nov 28, 2007 IP
  14. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #14
    I'm using MSAccess 2000 with php. With the Apache Server.
     
    gilgalbiblewheel, Nov 28, 2007 IP
  15. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    gilgalbiblewheel - Commandos is correct. From looking at your errors. You are using SQL server. And there is no 'limit' for SQL server.

    SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY text_data) as row FROM book ) a WHERE row > 5 and row <= 10
     
    vonvhen, Nov 28, 2007 IP
  16. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #16
    But if I want to lay out the following pages 10 at a time then is this still good?

    what's a before WHERE and why row > 5?
     
    gilgalbiblewheel, Nov 28, 2007 IP
  17. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    the following code i believe will return row 6, 7, 8, 9 and 10.

    If you want to display 10 pages, then you will change the WHERE clause to something like row > 0 and row <=10.

    And to make it dynamic, you can replace the '0' and '10' with variables (e.g. row > $beginRow and row <= $endRow). Where $beginRow and $endRow will store your pages.
     
    vonvhen, Dec 3, 2007 IP
  18. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #18
    I changed to mysql ( from MS Access ).

    I have this so far:
    $perpage = 10;
    $start = (!empty($_GET['start'])) ? $_GET['start'] : 0;
    
    $sql.= " LIMIT " . $start . "," . $perpage;
    PHP:
    What am I missing to go on to page 2?
     
    gilgalbiblewheel, Dec 19, 2007 IP