Copy link to clipboard
Copied
I have a display page which shows 6 records at a time with First/Prev/Next/Last available as appropriate. When I navigate away from the page to add a new record, delete a record, or edit a record, I come back to the first page. Is there a way to return to the same page? I have tried using session variables without success. Is there a way to send TWO variables to the next page? ie Show.php?var1=$var1&&var2=$var2? Thanks for any advice!
Well you can certainly send 2 variables in the link:
<a href="show.php?variable_1=Something&variable_2=Somethingelse">Show</a>
Have a look at the php script which generates the pagination for First/Prev/Next/Last and more so have a look at the source code in your browser, which is generated from the script. It might reveal information about how the links are working out which page of database results to display. If you can determined that then all you should need to do is send the php variable,
...Copy link to clipboard
Copied
Not knowing the exact conditions that ypu have created, this may be of use: https://www.w3schools.com/jsref/met_his_back.asp
Copy link to clipboard
Copied
I don't know how you have your 'First/Prev/Next/Last' navigation set up BUT when you click on any of those options they must be sending information to the pagination php script on your page which gets and delivers the correct page to view.
If you can identify the php variable being populated or created by the 'First/Prev/Next/Last' options when clicked then you can pass it between pages using a url parameter and after you have finished your editing you can use that parameter in a url string to go back to the original page and query the script which will get the correct page to view based on what is being passed to it in the url parameter.
Copy link to clipboard
Copied
I need to clarify because I think I'm using the word "page" in 2 senses. I have a page that shows 6 records at a time from a table. There is navigation First/Prev/Next/Last. There is also the option to ADD a new record, edit one of the records, or delete one of the records. In each of the 3 latter situations, I call a different php page and then return to the display page. In the case of add and delete, I might put up with returning to the FIRST 6 records in the table, but I'd prefer, particularly after editing a record, to return to the same set of records on display when I left. I've tried setting a record set #, the previous next record #, and the previous previous record # in a session variable, but so far it's not working. I hope this makes sense! If it's possible to send TWO variables in the hyperlink that would help a lot, but I haven't figured that out...
Copy link to clipboard
Copied
Well you can certainly send 2 variables in the link:
<a href="show.php?variable_1=Something&variable_2=Somethingelse">Show</a>
Have a look at the php script which generates the pagination for First/Prev/Next/Last and more so have a look at the source code in your browser, which is generated from the script. It might reveal information about how the links are working out which page of database results to display. If you can determined that then all you should need to do is send the php variable, which shows the correct page of results to display, to your editing page via the editing link then you can redirect back to your master page, which shows the database results, using a php location redirect, after you have finished the editing process.
And yes this is not a good idea for adding and deleting but editing should work as the information should remain 'static'.
Copy link to clipboard
Copied
Thanks! I will try all that you suggested.
Copy link to clipboard
Copied
I tried sending two parameters, but when I do, I get
<a href="show.php?variable_1=Something%20&variable_2=BLANK">Show</a>
I have no idea where the %20 came from, but my second parameter didn't get there.
Copy link to clipboard
Copied
Same happens when I use
Header("Location: Routine2.php?var1=$var1&var2=$var2");
Copy link to clipboard
Copied
Kept at it and finally was successful. Typos!!!!!! I appreciate your help in solving my problem. THANKS!
Copy link to clipboard
Copied
Kept at it and finally was successful.
Good job, well done. Truth be known that's what we all do. The secret is building up enough knowledge to be able to logically work out if a process seems possible, then a little trial and error, while trying to avoid the one or two typo errors.