View Single Post
  #3  
Old 08-19-2006, 09:57 AM
matthew matthew is offline
OSP Starters
 
Join Date: Apr 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
matthew is on a distinguished road
Default

You have to have primary key in your table and then you can do something like

PHP Code:
while ($row = mysql_fetch_row($result))
{
$thisId = $row["Id"];
}

$lastId = $thisId - 1;
$nextId = $thisId + 1;

and if you want to select complete records of next and prev ids then write queries based on last and next ids vars,

PHP Code:
select * from tb where id=$lasdId
select * from tb where id=$nextId -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - next and previous record from table
View Single Post
  #3  
Old 08-19-2006, 09:57 AM
matthew matthew is offline
OSP Starters
 
Join Date: Apr 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
matthew is on a distinguished road
Default

You have to have primary key in your table and then you can do something like

PHP Code:
while ($row = mysql_fetch_row($result))
{
$thisId = $row["Id"];
}

$lastId = $thisId - 1;
$nextId = $thisId + 1;

and if you want to select complete records of next and prev ids then write queries based on last and next ids vars,

PHP Code:
select * from tb where id=$lasdId
select * from tb where id=$nextId -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote