Thread: Server status page, Multiple pages

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Server status page, Multiple pages 
    Renown Programmer

    Nikki's Avatar
    Join Date
    Aug 2008
    Posts
    3,993
    Thanks given
    553
    Thanks received
    1,077
    Rep Power
    5000
    If a page has more than 20 SQL results how would i make it make a new page with the next set of results? im not really familiar with SQL querys, i use this code to print each Query to the table.
    Code:
    if ($Result) {
    while ($Row = mysql_fetch_array ($Result)) {
    @mysql_connect($Host, $User, $Password) or die(mysql_error());
    @mysql_select_db ($DBName) or die(mysql_error());
    $checkCurr = @fsockopen("$Row[IP]", "$Row[Port]", $ERRNO, $ERRSTR, 1);
    $total = "$Row[Total] + 1";
    
    echo ('<tr>');
    echo ('<td class="lista">');
    echo ("<a href=serverstatus.php?server=$Row[IP]><b>$Row[Name]</b></a>");
    echo ('</td>');
    echo ('<td class="lista">');
    print ("$Row[IP]");
    echo ('</td>');
    The $Row is the query, So im wondering how after a certain number it puts the next set to next page?
    Please don't add/pm me asking for RSPS help!

    Links:
    - [Only registered and activated users can see links. ]
    - [Only registered and activated users can see links. ]

    Reply With Quote  
     

  2. #2  
    John Doe
    Guest
    Use some form of offset, and then on the main page display where the offset starts.

    Example:

    Code:
    
    status.php?offset=20;
    Would start at #20

    Get it?
    Reply With Quote  
     

  3. #3  
    Renown Programmer

    Nikki's Avatar
    Join Date
    Aug 2008
    Posts
    3,993
    Thanks given
    553
    Thanks received
    1,077
    Rep Power
    5000
    Quote Originally Posted by John Doe View Post
    Use some form of offset, and then on the main page display where the offset starts.

    Example:

    Code:
    
    status.php?offset=20;
    Would start at #20

    Get it?
    or use a While statement like that, But add in there if($count=0 && $count <= 20? Idk rly I mean like how to start the Querys at 20, i know the methods, just need to know how to make the row start at 20
    Please don't add/pm me asking for RSPS help!

    Links:
    - [Only registered and activated users can see links. ]
    - [Only registered and activated users can see links. ]

    Reply With Quote  
     

  4. #4  
    Registered Member
    king free's Avatar
    Join Date
    Sep 2007
    Posts
    226
    Thanks given
    0
    Thanks received
    1
    Rep Power
    89
    [Only registered and activated users can see links. ]

    That should help you.

    EDIT:
    Code:
    if ($Result) {
    Don't do that. Read up on what mysql_query() returns, a resource id doesn't evaluate back to true, which means that statement should never complete. But if the query failed it would return false, and then it still wouldn't complete...
    DON'T GET v&

    Reply With Quote  
     

  5. #5  
    Renown Programmer

    Nikki's Avatar
    Join Date
    Aug 2008
    Posts
    3,993
    Thanks given
    553
    Thanks received
    1,077
    Rep Power
    5000
    Quote Originally Posted by king free View Post
    [Only registered and activated users can see links. ]

    That should help you.

    EDIT:
    Code:
    if ($Result) {
    Don't do that. Read up on what mysql_query() returns, a resource id doesn't evaluate back to true, which means that statement should never complete. But if the query failed it would return false, and then it still wouldn't complete...
    That would be when the Page returns a Mysql error i guess, Thanks that should help, so far page is looking good
    Unless i re do the whole page, i cant get it working. for some reason the page messes up
    Please don't add/pm me asking for RSPS help!

    Links:
    - [Only registered and activated users can see links. ]
    - [Only registered and activated users can see links. ]

    Reply With Quote  
     

  6. #6  
    is serisiuly cul.

    DJ Dan's Avatar
    Join Date
    Apr 2007
    Posts
    1,324
    Thanks given
    6
    Thanks received
    5
    Rep Power
    223
    Cleaned for you.

    Also, look up LIMIT (sql)

    e.g

    Code:
    $query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 0,30");
    Would display 30 rows.

    Code:
    $query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 15,30");
    Would display 15 rows.

    Its hard to explain because ORDER BY id changes everything.
    Reply With Quote  
     

  7. #7  
    Extreme Donator

    Join Date
    Jan 2008
    Age
    27
    Posts
    104
    Thanks given
    65
    Thanks received
    8
    Discord
    View profile
    Rep Power
    74
    Quote Originally Posted by DJ Dan View Post
    Cleaned for you.

    Also, look up LIMIT (sql)

    e.g

    Code:
    $query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 0,30");
    Would display 30 rows.

    Code:
    $query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 15,30");
    Would display 15 rows.

    Its hard to explain because ORDER BY id changes everything.
    Code #1 would get the first 31 rows (0-30)
    On code #1 you could do as easy as:
    Code:
    $query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 30");
    But that is what I would choose.

    if you do:
    Code:
    $query = mysql_query("SELECT * FROM table LIMIT 30");
    It will choose the 31 first row in the MySQL database that you input in it.


    Code #2 would get the rows from 15 (16 acctually, because MySQL counts in 0) to 30

    Order by is set to ASC as default, and by this I mean that it counts from bottom to top. (1, 2, 3, 4, 5, 6 etc.)


    It is kindof hard to explain, but if you need some help, mail me on:
    [Only registered and activated users can see links. ] <-- Not for chatting, only e-mail.
    Don't bother pming me, I never checks pms anyway, and if you want my chatmail, mail me asking for it.
    Reply With Quote  
     

  8. #8  
    Brugerman
    Guest
    It's called pagination if i'm correct.
    just google it if the posts before this one didn't help.
    heaps of tutorials on how to use it.
    Reply With Quote  
     

  9. #9  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,074
    Thanks given
    2,625
    Thanks received
    3,579
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by king free View Post
    Don't do that. Read up on what mysql_query() returns, a resource id doesn't evaluate back to true, which means that statement should never complete. But if the query failed it would return false, and then it still wouldn't complete...
    It will check if the resource is valid so it will indeed work.

    And you should note you can use a range in the LIMIT, so you probably want to do:

    LIMIT offset, number of results
    .
    Reply With Quote  
     

  10. #10  
    Registered Member
    king free's Avatar
    Join Date
    Sep 2007
    Posts
    226
    Thanks given
    0
    Thanks received
    1
    Rep Power
    89
    Quote Originally Posted by Graham View Post
    It will check if the resource is valid so it will indeed work.

    And you should note you can use a range in the LIMIT, so you probably want to do:

    LIMIT offset, number of results
    Thinking about it, you're right, if($var) also does the same job pretty much as, if(isset($var)) as well as, if true etc.
    DON'T GET v&

    Reply With Quote  
     

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)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •