# Move to next record query

**URL:** <https://forum.kirupa.com/t/move-to-next-record-query/217954>\
**Category:** Uncategorized\
**Created:** [March 3, 2007, 11:35am UTC](https://forum.kirupa.com/t/move-to-next-record-query/217954 "2007-03-03T11:35:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onemhunki](https://avatars.discourse-cdn.com/v4/letter/o/c57346/32.png) [@onemhunki](https://forum.kirupa.com/u/onemhunki)\
**Post date:** [March 3, 2007, 11:35am UTC](https://forum.kirupa.com/t/move-to-next-record-query/217954/1 "2007-03-03T11:35:52Z")

</div>

I’ve got an internal message system which displays the message correctly, I want to create a next button on the page which moves to the next unread message.

```php

$query2 = "SELECT * FROM messages WHERE receiver = '$receiver' AND status = 'u'";
$result2=mysql_query($query2);
while($row2=mysql_fetch_assoc($result2)){
echo $row2['message_ID'];
echo "</br>"; 
}

```

This gives me a list of all the message\_ID’s that are to the recipient and are unread. If the current message\_ID is 16, how do I move to the next record, baring in mind it may/maynot be the next sequential number.

Any help as usual appreciated.

Cheers
