Displaying individual records
| From: | Mick Lloyd | Date: | Sun, 14 May 2000 11:00:50 +0000 |
| Subject: | Displaying individual records | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16@lists.php.net to get a copy of this message | ||
I have a script to select records as follows:
$result=mysql_query("select * from $TA order by Last_Name");
$rows=mysql_num_rows($result);
and am trying to navigate amongst the selected records using statements such
as:
echo "<A HREF = '$php_self?navigate=Next>Next</A>";
$navigate is used in switch as follows:
switch($navigate) {
case "";
$profile = 0;
break;
case "First";
echo "Clicked First<P>";
$profile = 0;
break;
case "Previous";
echo "Clicked Previous<P>";
if ($profile <> 0) {
$profile = $profile - 1;
}
else {
$profile=0;
}
break;
case "Next";
echo "Clicked Next<P>";
if ($profile <> $rows) {
$profile = $profile + 1;
}
else {
$profile = $rows;
}
break;
case "Last";
echo "Clicked Last<P>";
$profile=$rows-1;
break;
}
The 'First' and 'Last' of these work but 'Next' and
'Previous' do not work
properly. The variable $profile is used to get individual records using:
mysql_data_seek($result,$profile);
The script then calls a function - showprofile($result,$profile,$rows); -
with the values of $result, $profile and $rows to show individual records
based upon the value of $navigate.
I guess the problem is something to do with calling the script which reruns
the select as well as resetting the value of $profile. I have tried other
ways but without similar levels of success (ie none). I would like to be
able to run the select once only and then choose which records to show based
upon a user's selection (using $navigate or similar).
Any help/advice gratefully received. You may have guessed - I'm just
beginning to experiment with PHP!
Best regards
Mick Lloyd
mjl@consultingrooms.com