|
Posted by ClickToWalk on 10/11/43 11:53
"ClickToWalk" <admin@clicktowalk.com> wrote in message
news:44c148ae_2@mk-nntp-2.news.uk.tiscali.com...
> "-Lost" <spam_ninjaREMOVEME@REMOVEMEcomcast.net> wrote in message
> news:ZZOdnb6a56HslFzZnZ2dnUVZ_tidnZ2d@comcast.com...
>> "ClickToWalk" wrote in message
>> news:44bfb933$1_4@mk-nntp-2.news.uk.tiscali.com...
>>
>>> This is a bit of code that I have used to successfully echo all the
>>> available records - with gaps where records are missing - but what
>>> modifications do I need to make to it so that only one row is returned
>>> from the recordset, determined by $id.
>>
>> You could throw an if clause in checking the number of rows returned
>> (mysql_num_rows) or even possibly check with mysql_affected_rows
>> (assuming an INSERT, DELETE, or UPDATE).
>>
>> You could also LIMIT your results and output those three rows [previous,
>> current, next].
>>
The LIMIT clause was exactly what I was missing, I modified my query as
below.
$query = "SELECT *
FROM tbl_locl
LIMIT $id, 1";
where $id is taken from the page url the second parameter in LIMIT is set to
1 as I'm paging through the records one at a time.
I also added the following to the code to return the last available record
$query_last = "SELECT *
FROM tbl_locl";
$result_last = mysql_query($query_last);
$row_last = mysql_num_rows($result_last);
$row_last = ($row_last-1);
Now I use the following to generate the links to for First/Prev/Next/Last
first: $id=0
prev: $id -1
next: $id+1
last: $row_last
Thanks for the pointer Lost, saved me a big headache.
Regards
Matt
[Back to original message]
|