See below the answer
to your previous question which has been automatically removed due to abuse report:
Sorry, the question makes little sense. You can change any variable regardless the purpose of this variable. First of all, you should have indicated that the question about the PHP used in a Web site, because PHP can be used in a stand-along way. On a page, you cannot run the script interactively. This is not how Web works. You need to have a page with controls, such as buttons and input controls. You need to take value of controls and send an HTTP request to the same or another page. This another page should handle the request and create HTTP response. In this response, you can re-calculate data.
Now, to send HTTP request, you can use the form
element, and you need at a submit button <input type="submit">
. You also need the attribute action
(URL) and specify the method, such as "post". On server side, you can use PHP $_POST
:
http://php.net/manual/en/reserved.variables.post.php[^].
Alternatively, to send an HTTP request, you can use JavaScript and AJAX:
https://en.wikipedia.org/wiki/Ajax_%28programming%29[^],
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp[^].
In this case, form is not needed. Using the form is much simpler. Please see: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data[^].
This is all you need.I must admit that your previous question was much clearer than the present one, so it deserved some answer. Even though the particular problem wasn't clearly pointed out, your post suggested that you had some misunderstanding which can be fixed.
Perhaps understanding of all that may help you to solve the problem you formulated in the present question. But I agree with all the comments to the question you got. You need to explain your problem in much more detail. Your complains about treating your badly are simply inappropriate; I don't event want to discuss it any further.
Perhaps you need to shorted your code as much as possible, but focus on one particular problem and add decent description. If you thing you have a bug, you need to describe precisely how it is manifested. Also, you have to describe your ultimate goals, explain what exactly you are trying to achieve and how.
Sorry for incomplete answer, but I think next step should be yours. I agree with the comment to the question by PIEBALDconsult who mentioned that "That's a step in the right direction".
—SA