How do I code my Previous/Next Button to show next item
Posted: Thu Jan 10, 2013 3:45 am
Hello Friends,
I need your help. I have a website where articles are submitted. On the read_article.php page, i retrieve my data from the mysql DB like this.
I did my Previous and next button like this
<a href='read_article.php?id=<?php echo $id--; ?>'>Previous Article</a>
<a href='read_article.php?id=<?php echo $id++; ?>'>Next Article</a>
if the current Article $id is 5, Clicking on Next Articles will show Articles whose $id is 6. But in case articles with $id 6,7 & 8 have been deleted, meaning the next available article is 9.
How do I make my next button go straight from $id 5 to $id 9
Thanks
I need your help. I have a website where articles are submitted. On the read_article.php page, i retrieve my data from the mysql DB like this.
Code: Select all
<?php
$id = $_GET[id];
$get = mysql_query('SELECT * FROM articles WHERE id='$id'');
$rows = mysql_fetch_array($get);{
$id = $rows[id];
$topic = $rows[topic];
$body = $rows[body];
}
?>
<a href='read_article.php?id=<?php echo $id--; ?>'>Previous Article</a>
<a href='read_article.php?id=<?php echo $id++; ?>'>Next Article</a>
if the current Article $id is 5, Clicking on Next Articles will show Articles whose $id is 6. But in case articles with $id 6,7 & 8 have been deleted, meaning the next available article is 9.
How do I make my next button go straight from $id 5 to $id 9
Thanks