Each page i have is in a different record in the database and i would like to know how to automatically at a previous and next page links with a description of the *next* page as the link??
| SitePoint Sponsor |





Each page i have is in a different record in the database and i would like to know how to automatically at a previous and next page links with a description of the *next* page as the link??





I presume that you've added ID columns in the database (ranging from 1 to infinity and auto_increment). If you've that, you must keep the ID of the current article in a variable available. For the 'back' button/link you simply decrease the ID by 1 and for the next button you increase it by 1.
Then somewhere on the page you echo() the links to the script that you use to grab the articles out of db. It should look something like this:
<a href=\"view-page.php?page=" . $back . "\">back</a>
and:
<a href=\"view-page.php?page=" . $next . "\">next</a>
//echo() the description of the next page somewhere on the
//page, like below the URL (I assume you've a description
//ready in the db)
Good luck
<Edited by Elledan on 01-04-2001 at 10:20 AM>
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.





I have fields called: PID and AID
AID = article id
PID = pid





Elledan what happens when you delete a record wioth say ID number 3 and you alread yhave 50 records. That doesn't get reassigned so if your next link looked for 3 it wouldn't find it I think you would be better off to use those numbers that you pass as offsets with a limit of one in your query
like mysql_query("SELECT * from table LIMIT $next, 1");
Please don't PM me with questions.
Use the forums, that is what they are here for.





So how would i go about this.
AID stays constant for whole article while PID changes.
What would i put on my page. Just for previous and next links. Making sure there is no previous link on the first page and a next on the last page?
URL's look like this:
http://www.codingclick.com/article.php?aid=1&pid=1





Also, i couldn't find this in the forums before, but if i wanted a print template and had to join all of the pid's together to form one big article. How would i do this, and make sure they are in order?
Sorry for any inconvenience caused



I guess its kindof late .. hehe.. but i just finished writing a code snippet on the subject of creating next / prev links .. which would work with the form you have the database setup right now ...
url as follows:
http://www.geekarea.org/articles.php?action=show&id=12
cogito, ergo sum
Should I use as 32 bit or 64 bit integer to store infinityOriginally posted by Elledan
I ... ranging from 1 to infinity and auto_increment ...![]()
Bookmarks