I tried to search the forums but couldn't find same issue.
I am running a script to find the "Previous" and "Next" records, the problem is when I get to record 1 I get the error below, same with when I reach the last record in the db.
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 18
Here is the script running it, do I need to add to the query? or how can I use IF/ELSE?
<?php
$id = $_GET['id'];
// Retrieve your record according to id
// Display Record
// Links to Previous Records
$query = "SELECT id FROM jokes WHERE category = '$category' AND id < $id ORDER BY id DESC LIMIT 1" ; // For Previous
$result = mysql_query($query) ;
$rowp = mysql_result($result,0); // $rowp has Previous record id
$query2 = "SELECT id FROM records WHERE id > $id ORDER BY ASC LIMIT 1"; // For next Record
// Links to Next Records
$query = "SELECT id FROM jokes WHERE category = '$category' AND id > $id ORDER BY id ASC LIMIT 1" ; // For Next
$result = mysql_query($query) ;
$rown = mysql_result($result,0); // $rown has Next record id
$query2 = "SELECT id FROM records WHERE id < $id ORDER BY ASC LIMIT 1"; // For previous Record
?>
<center>
<a href="jokecontent.php?id=<? echo "$rowp"; ?>">Previous Joke</a>
<a href="jokecontent.php?id=<? echo "$rown"; ?>">Next Joke</a>
</center>