sabecs
asked on
MySQL - get next record id from results
Hi,
I have the following query which returns a result set and loops through to display the different records. Is there a way to get the id of the record coming next, perhaps using mysql_data_seek?
mysql_select_db($database_ conn_data, $conn_data);
$query_view_items = "SELECT * FROM items ORDER BY sortid";
$view_items = mysql_query($query_view_it ems, $conn_data) or die(mysql_error());
$row_view_items = mysql_fetch_assoc($view_it ems);
do {
//get current record id
$id = $row_view_items['id'];
//code here to push pointer forward by one
$next_id = $row_view_items['id'];
//code here to move pointer back by one
......
...
} while ($row_view_items = mysql_fetch_assoc($view_it ems));
Thanks in Advance for your feedback.
Cheers,
Andrew
I have the following query which returns a result set and loops through to display the different records. Is there a way to get the id of the record coming next, perhaps using mysql_data_seek?
mysql_select_db($database_
$query_view_items = "SELECT * FROM items ORDER BY sortid";
$view_items = mysql_query($query_view_it
$row_view_items = mysql_fetch_assoc($view_it
do {
//get current record id
$id = $row_view_items['id'];
//code here to push pointer forward by one
$next_id = $row_view_items['id'];
//code here to move pointer back by one
......
...
} while ($row_view_items = mysql_fetch_assoc($view_it
Thanks in Advance for your feedback.
Cheers,
Andrew
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help.
Open in new window