I need help on this:
How do I pass a value from one variable to another variable upon users click?
I have following html site
some php codes here
how do make a function here (onclick) change those Global Variable defined above(myGloablVarA,myGloablVarB,myGloablVarC)
to new values thats been generated upon user click?
currently I am posting the value to url location
instead of posting the values to url location I
would like values to be stored in global varaibles and....
.....read the values back here again
myVarnew1=myGloablVarA; // assign new values from myGloablVarA
many thanks..I would be very glad on any tips
You cant. PHP fully executes before the first character of information is sent to the user, so by the time they see it there is nothing running to switch. I also do not think you understand how global variables work. Global variables do not outlast the application which they are defined in, they are deleted along with everything else when the script finishes running.
I've seen this type of logic from beginners before, and its pretty understandable. What I would recommend to help you better understand what is going on is to divide up your file into two sections, one where you're doing PHP work and the other where you're outputting HTML, sort of like this:
//do all your data manipulation here
$someVar = $someOtherVar;
//then, below here you can put all your html
<h1>this is an html page.</h1>
the value of a variable prepared above is <?php echo $someVar ?>.
Also, you should read a bit about how web servers work in general. The process is typically (for a php file) like:
1. a web user requests a page (www.example.com/myPhpFile.php)
2. the server runs the php file which creates html
3. the server sends that html back to the user who requested it
4. the user's browser turns that html into a working webpage
4. the user will click something which will either request a different page, or it will send a request along with some data. The server will handle that data and then send back the resulting html again.
You'll want to send the data using forms for now
If you let us know a bit more concretely what you want to accomplish we can help a bit more