Good afternoon, we have a table with news id | 5 | 7 | 15 | 20 | : id | 5 | 7 | 15 | 20 | id | 5 | 7 | 15 | 20 |
And request:
$query = "select * from articleviews order by articleid desc limit 1"; $results = mysql_query($query,$connection) or die(mysql_error()); $lastid = mysql_fetch_array($results); //Previous link $previousid = $_GET['id']-1; if ($previousid < 1) { $previous = ""; } else { $previous = '/article.php?id='.$previousid; } //Next link $nextid = $_GET['id']+1; if ($nextid > $lastid['id']) { $next = ""; } else { $next = '/article.php?id='.$nextid; } But in the end, only the id from the open news is inserted into the link. For example, on news with id 15, the previous link will be on news with id 14, not 7. Help to bring existing id to news.