Page 1 of 1

problem with link

Posted: Thu Mar 10, 2005 12:56 pm
by maboroshi
Hi I am having a problem with this code

Code: Select all

<?php

$link = mysql_connect("local", "user", "pass");

if (!$link) {
	print "Error connecting to database";
	exit;
	}
	
	if (!@mysql_select_db("engrooved")) {
		print "Could not select Database";
		exit;
		}

if(!$rowstart) $rowstart=0;
$numrows=mysql_num_rows($result2);


$result = mysql_query("select * from knowledge order by title asc limit $rowstart,20");
$result2 = mysql_query("select * from knowledge");

	
	if ($result && @mysql_num_rows($result) > 0 ) {
		while ($row = mysql_fetch_array($result))
			{

			$myid = $row['id'];


				

?>

<A HREF="moredata.php?moredata=<? echo $myid ?>"><? echo $row['title']; ?> </A><BR>

<?
}
}			
		else {
			print "Sorry Nothing Yet";
			}
			
?>


<br>
<br>


<?php


		
if ($rowstart>$numrows) 
{ ?>	
<A HREF="<? echo $PHP_SELF ?>?rowstart=<? echo $rowstart-20;?>"> 
< Previous Page</A>
| 
<?
}
$numrows=mysql_num_rows($result2);
if($rowstart+20<$numrows) 
{?>
<A HREF="<? echo $PHP_SELF ?>?rowstart=<?echo $rowstart+20;?>">
Next Page ></A>  

<?			
}		
		mysql_close($link);
?>
I am unsure how to get the next previous links working properly

Any ideas are appreciated Cheers

Maboroshi


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Thu Mar 10, 2005 1:31 pm
by Joe
Do you mean something like:

Code: Select all

<A HREF=&quote;javascript:history.back()&quote;>< Previous Page</A>

Hello

Posted: Thu Mar 10, 2005 2:46 pm
by maboroshi
Sorry No

I am looking at displaying a list of 20 items from a database per page. Basically the next previous links will go through the database displaying either the next 20 or the previous 20

Posted: Thu Mar 10, 2005 3:11 pm
by John Cartwright
search "pagination".

There is even a code snipplet for it at Code-Snipplets