Skip to content
Advertisement

PHP – change/adding numerical value to array key value using submit button

I am using array to limit the results from glob(), like a pagination

JavaScript

How can I add value of 1 to $show[0] using a button?

JavaScript

Advertisement

Answer

You’ll need to record the current state of the page in some way. You can do this with a hidden variable, however I would recommend either switching to $_GET for this function, or simply using a query string (as I’ve done here). That way you can go to the correct pagination directly in the browser URL bar.

PHP code:

JavaScript

Then you can do something like this for the HTML form (using the query string method I mentioned)

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement