Cannot submit on click of a button using POST method in moodle
I am working in moodle, and basically trying to add a few features to Quiz Activity as a part of my project.
Since I am novice to moodle and PHP I need some help in PHP coding.
I have built a web page using "Add a resource" in moodle and I am writing the code in its view.php file.
I am trying to load all question ids for a particular quiz in an array and when the page loads for the first time (view.php) I am trying to print the first two values of array as follows: Current Question displayed: array and Next Question displayed: array
So the value at array position should get stored in another temporary table called quiz_currentquestion which has a field (currentquestion).
Now on click of Add button, the existing value should get deleted from quiz_currentquestion table and the new value that is the array should be inserted into the table. (i.e. every time there would be just one record in quiz_currentquestion table)
Thus on click of ADD button, the string being displayed on screen should get incremented. i.e. Current Question wil nw be :array and Next question would print: array.
But on click of button, it again executes the entire code and thus the prev value doesn't get stored in the database at all.
Is it something to do with submit button, or the logic written in PHP is wrong. Please let me know as I have been trying this thing since last 3 days and am clueless so as to what is the possible reason behind this.