The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Prev & Next Button
Hi
I am new to php and i`m enjoying learning it. I have just started on databases and come across a slight problem: I need to display records of 10 the have a next and prev button to display the remainder of the records. I have seached all over the net but the code i have come across is all Chinese to me - here is the code i have so far: <? $server= "myserver"; $user= "myaccount"; $password= "pass"; $database= "database1"; $table= "table1"; MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>"); MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); $result=MYSQL_QUERY( "SELECT * FROM $table order by name "); if(mysql_num_rows($result)) { // it is true, so let's print the results to the browser while($row = mysql_fetch_row($result)) { print (" $row[0] "); ?><? print (" $row[1] "); ?><? print (" $row[2] "); ?> <? } } else { // false, no results } ?> thats the code i am using so could someone please help me where to place the code for displaying the next records etc... Thank you very much Lee The PHP Newbie ! |
#2
|
|||
|
|||
Use the LIMIT option in mysql, and make a next and previous link that contain 10 more or less than the current limit.
PHP Code:
|
#3
|
||||
|
||||
thanks for your help but i get the following error :
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' on the line: echo "<a href=\"$_SERVER['PHP_SELF']?limit=$nextlimit\">next</a>"; Any suggestions ? Thanks |
#4
|
||||
|
||||
echo "<a href=\"$_SERVER['PHP_SELF']?limit=$nextlimit\">next</a>";
to echo "<a href=\"$_SERVER[PHP_SELF]?limit=$nextlimit\">next</a>"; |
#5
|
||||
|
||||
Great it worked thanks for that. Just one more question then my tutorial is done. How do i only display the buttons if they are needed i.e first 10 i dont need the previous button and the last ten dont need the next button . Sorry for the trouble !
Thanks Again to both of you |
#6
|
||||
|
||||
Does anyone have the solution to the above question ? If so could you explain how ?
Thanks |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|