problem with link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maboroshi
Forum Commoner
Posts: 25
Joined: Thu Nov 13, 2003 10:10 am

problem with link

Post 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]
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Do you mean something like:

Code: Select all

<A HREF=&quote;javascript:history.back()&quote;>< Previous Page</A>
maboroshi
Forum Commoner
Posts: 25
Joined: Thu Nov 13, 2003 10:10 am

Hello

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

search "pagination".

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