Hi!
Ive been trying to paginating my articles. First Ive been trying with this script:
$goin_back = $sub_action - 1;
$goin_ahead = $sub_action + 1;
$NEXT = "<a href='content.php?article.$goin_ahead'>next article >></a> ";
$PREV = "<a href='content.php?article.$goin_back'><< previous article</a> ";
echo "$PREV";
echo "$NEXT";
$sub_action is the article_id for example article.4
this works but the problem is that the article_id:s arn't like: 1,2,3,4,5,6,7 ...
some of the id:s are missing so the articles_id:s are more like: 1,3,6,8,11,15 ...
therefor ive been thinking that there should be a way of calling for the next and previous row in the database instead of the previous and next article_id.
How can I do this?
Anyone knows a code, maybe similiar to mine above but selecting the next row instead of next article_id???
Also how can make the next link dissapear when you have reached the last row in the databastable and same thing with previouslink when you reach the first row?
Something like:
if($sub_action < FIRST ROW IN THE TABLE){
$PREV = "";
}
if($sub_action > LAST ROW IN THE TABLE){
$NEXT = "";
}
Thanks for your help!
Perd