Yes, you can do as leetcrew suggested and add an id field to which you can add or subtract in order to get the previous or next name. The problem is that if you insert a new name between two existing names, then you must rebuild the numeric index each time a name is added or it becomes useless.
Example:
01 - Jane
02 - John
Insert Jim - id = ?
You can do this another way by using the member name as the index, and then creating a sort of descending member name index with with strtr. Then you can use inequalities to always get the next/previous name.
Here is an example of building the reverse index for Jane (I'll let you handle the nuances of upper and lower case)
$member = "jane";
$revmem = strtr($member,
"abcdedfgijklmnopqrstuvwxyz",
"zyxwvutsrqponmlkjihgfedcba");
So, jane would end up as qzmv, john would be qlsm, allen would be zoovm, and zoo would be all. So, you have a reverse index. You create indexes on member_name and reverse_name. Kind of like taking the two's complement of a alpha string.
Now all you need is a script that passes a forward name and a backward name along with a direction. The script gets called with a name as a passed variable. For the very first name in the table, pass a space which has a lower collating value then the first name in the table
Then the script might look like this.
memberdetails.php?nextname=' '&priorname=' '&dir=1
<?php
// if the direction is forward (dir = 1) then we do a greater than
// search on the next name, otherwise we do a search on the
// reverse index.
if (dir==1)
{
$query = "SELECT * from member_table
WHERE member_name > $nextname
LIMIT 1";
}
else
{
$query = "SELECT * from member_table
WHERE reverse_name > $priorname
LIMIT 1";
}
// get the single record you want.
$result = mysql_query ($query) ;
$row = @ mysql_fetch_array($result);
$nextname = $row["member_name"];
$priorname = $row["reverse_name"];
// put out what ever stuff you want on the page, then
// build the next/prior links
echo "<a href=\"memberdetails.php?nextname=$nextname&priorname=$priorname&dir=1\">";
echo "View Next Member</a>";
echo "<a href=\"memberdetails.php?nextname=$nextname&priorname=$priorname&dir=0\">";
echo "View Previous Member</a>";
?>