I need help " Next page & Previous page "

Discussion in 'PHP' started by hexmax, Feb 16, 2009.

  1. #1
    Hello all

    I tired to create Next page & Previous page but fail to work with out error

    in Attach Files you will see my code there are important query

    select * from `$table_02` where `ts_09`='$_GET[link_id]'
    Code (markup):
    $table_02 ----> in my DB news
    ts_09 --------> in my DB link_id number

    Thank's
     

    Attached Files:

    hexmax, Feb 16, 2009 IP
  2. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    first of all dont use gpc variables directly.

    $link_id= (get_magic_quotes_gpc()) ? $_link_id['link_id'] : addslashes($_link_id['link_id']);
    PHP:
    what is error message?
     
    MC_delta_T, Feb 16, 2009 IP
  3. hexmax

    hexmax Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Display only 5 or 10 post and Next page empty or nothing I was use this code

    http://www.webmaster-talk.com/792581-post4.html
    Code (markup):
     
    hexmax, Feb 16, 2009 IP
  4. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    i dont get it. you want paging with attached codes? where is the LIMIT part?
     
    MC_delta_T, Feb 16, 2009 IP
  5. hexmax

    hexmax Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yes i want limet 10
     
    hexmax, Feb 16, 2009 IP
  6. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    so where is it? i didnt see any LIMIT word in your codes.
     
    MC_delta_T, Feb 16, 2009 IP
  7. hexmax

    hexmax Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I was use this way
    http://www.webmaster-talk.com/792581-post4.html
    Code (markup):
    but delete :(
     
    hexmax, Feb 16, 2009 IP
  8. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #8
    Danltn, Feb 17, 2009 IP
  9. websecrets

    websecrets Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Don't put "ts_09" in parenthesis...

    Use
    select * from `$table_02` where ts_09='$_GET[link_id]'

    Instead of..
    select * from `$table_02` where `ts_09`='$_GET[link_id]'

    What other errors are you getting?
     
    websecrets, Feb 17, 2009 IP
  10. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #10
    Yes Pagenation is the best script for doing what you want and is easily customized.
     
    mokimofiki, Feb 17, 2009 IP
  11. hexmax

    hexmax Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    hexmax, Feb 17, 2009 IP
  12. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #12
    I can but try it yourself first and post what you come up with and we can fix it from there....

    The website that the pageination is on has tutorial videos that actually use it. I think the best one if the forum video 10 or 11 ... its the one dealing with replies
     
    mokimofiki, Feb 17, 2009 IP
  13. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #13
    I've posted a whole simple pagination script somewhere else on the forum. Although it bears repeating, I don't want to be redundant so I'll just give you the gist of it.

    You will need some thing like this:
    <?php
    $page     = $_GET['page']; // Define how you should know which results to display
    $perPage = 5; // 5 Results per page
    if(!isset($page) OR !is_numeric($page)){
      $page = 1; // If page is not set or is set to a non-numeric character, default back to page 1 :)
    }
    $limit      = $perPage*($page-1); // This is what we want to be our starting point for results.
    
    // MySQL Stuff
    mysql_connect("localhost","USER","PASS");
    mysql_select_db("DATABASE_NAME");
    
    // Run the query
    $query = mysql_query("SELECT * FROM prefix_table ORDER BY date DESC LIMIT ".$limit.", ".$perPage.";");
    
    while($row = mysql_fetch_array($query)){
      print "<h1>".$row['title']."</h1>".$row['post']."<br /><br />";
    }
    
    mysql_close();
    
    ?>
    PHP:
    Something simple like that should work. To make links all you would need to do is some simple while($link < $total){ print "<a href="$linkno">$linkno</a>"; $linkno++; $link++; } just for sake of a simple example.

    Regards,
    Dennis M.
     
    Dennis M., Feb 17, 2009 IP