|
Posted by Hilarion on 07/25/05 15:44
>> It would also not work OK after deleting some records, because you
>> would have gaps in ID order and "$id + 1" could hit such gap.
>
> You are right.
> The delete function do not call the same script!
This does not matter.
> But I will try the mentioned solutions at the top of this thread,
> who should give me the next and previous ID in the alphabetic order.
It'll solve problem with ID gaps but will not protect you from
problems when two users acting on the data at the same time.
Let's say that in alphabetical order the record with ID 321 is just
after record with ID 123. Two users have entered the page which
displays the record with ID 123. The page is identical for both
users and contains link:
<a href="adresse_edit.php?id=321">
<img border="0" src="images/co_avant.png" width="32" height="24"></a>
which leads to next record (with ID 321). One user clicks the
link and gets the page which displays the record 321 (the other
user is still watching the 123), and he clicks "DEL" and deletes
the record 321 (does not matter if it's the same script or not).
The second user stops watching 123 and clicks "next" button and
gets to URL "adresse_edit.php?id=321". Unfortunately there's no
321 record, so he gets error message or empty page or something
like that.
One of the solutions is to replace "next" (and "previous") link (which
is now calculated alphabeticaly when the current record is displayed):
<a href="adresse_edit.php?id=<?= $next_id ?>">
<img border="0" src="images/co_avant.png" width="32" height="24"></a>
with link:
<a href="navigate.php?id=<?= $id ?>&action=next">
<img border="0" src="images/co_avant.png" width="32" height="24"></a>
And the "navigate.php" would calculate (alphabetically) the ID
of the next (or previous - according to "action" parameter) record
and redirect to "adresse_edit.php" with proper ID.
> If you like I can send you this script after my holidays to speak
> about it.
OK, but I'll be off the Internet from saturday (for two weeks), so
do not expect quick reply :)
Hilarion
Navigation:
[Reply to this message]
|