Use some form of offset, and then on the main page display where the offset starts.
Example:
Would start at #20Code:status.php?offset=20;
Get it?
|
|

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.
The $Row is the query, So im wondering how after a certain number it puts the next set to next page?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>');
Use some form of offset, and then on the main page display where the offset starts.
Example:
Would start at #20Code:status.php?offset=20;
Get it?
[Only registered and activated users can see links. ]
That should help you.
EDIT:
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...Code:if ($Result) {
Cleaned for you.
Also, look up LIMIT (sql)
e.g
Would display 30 rows.Code:$query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 0,30");
Would display 15 rows.Code:$query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 15,30");
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:
But that is what I would choose.Code:$query = mysql_query("SELECT * FROM table ORDER BY id LIMIT 30");
if you do:
It will choose the 31 first row in the MySQL database that you input in it.Code:$query = mysql_query("SELECT * FROM table LIMIT 30");
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.
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.




| « [php + mysql] Need help with an error. | You can't do this! Can you make... » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |