0

I have a list of several hundred items. At any time a person can easily click on that item and see details of the item. But when they hit back button the php page takes the person back to the top of the list. Then that person has to scroll through the several hundred items to find that particular item again. My question is there a way for my php page to remember what item was clicked on last? This is a list that is on only ONE php page. NOT multiple pages. One page. They click on details that the form has and then they click out of the form still in the same page. I know that you can pass info between pages but what about on a single page?

  • Any code can "remember" any information that you persist in some place. A variable, a session value, a database, etc. Of course, when the user presses the back button, is PHP even involved at that point? Or is the browser just displaying what's already cached client-side? – David Sep 21 '16 at 14:29
  • When the back button is pushed the php is refreshed. And all cookies are lost. –  Sep 21 '16 at 14:37
  • Please note that they stay on the same php page. They don't go to a different page. –  Sep 21 '16 at 14:37

1 Answers1

0

Sure,

You can use anchors, for exemple :

<ul>
  <li id="item_1"><a href="/detail.php?id=item_1">Item 1</a></li>
  <li id="item_2"><a href="/detail.php?id=item_2">Item 2</a></li>
</ul>

And in detail.php :

<a href="/index.php#<?php echo $_GET["id"]?>">Back</a>
Sebastien
  • 6,640
  • 14
  • 57
  • 105
  • Will that work for hundreds of entries, without me having to code an unknowable list? Please remember that this list has at least 100 items and can have as much as 500 or even more. There is no limit to the length of this list. This is all coming in from a database call. So anything in the database can and will be called. And this list is dynamic. Not static. –  Sep 21 '16 at 14:41
  • No problem, juste generate an irl different for each Item id?> – Sebastien Sep 21 '16 at 14:56