Page 1 of 2
execute a php function when text is clicked [Solved]
Posted: Wed May 09, 2007 9:58 pm
by someguy4
wanted to know to execute a php function you click on some text
Posted: Wed May 09, 2007 10:00 pm
by John Cartwright
Can you be more specific?
Re: execute a php function when text is clicked
Posted: Wed May 09, 2007 11:41 pm
by thamizhchelvan
someguy4 wrote:wanted to know to execute a php function you click on some text
I think you are going to execute like JavaScript functions?.Note that you cannot do event handling using PHP. You can use AJAX for execute a PHP function in a remote page.
Posted: Thu May 10, 2007 1:18 am
by dibyendrah
How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like
http://xyz.com?word=x. I guess that will make a sense.
Posted: Thu May 10, 2007 1:47 am
by d3ad1ysp0rk
dibyendrah wrote:How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like
http://xyz.com?word=x. I guess that will make a sense.
How does that make it simple?
Anyways, we need more details. People are just guessing at what you want because the request makes no sense.
Re: execute a php function when text is clicked
Posted: Thu May 10, 2007 1:53 am
by linkmania
someguy4 wrote:wanted to know to execute a php function you click on some text
I am also expecting for a good solution
Posted: Thu May 10, 2007 4:36 am
by dibyendrah
d3ad1ysp0rk wrote:dibyendrah wrote:How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like
http://xyz.com?word=x. I guess that will make a sense.
How does that make it simple?
Anyways, we need more details. People are just guessing at what you want because the request makes no sense.
Oh well, from the query string, you can take the word and do whatever you like. I have written from my knowledge and I know better solutions are yet to come in this thread. I just took a participation hoping it will help someone.
Posted: Thu May 10, 2007 4:50 am
by CoderGoblin
Search for Ajax on these forums or as dibyendrah stated have a javascript onclick event send information to reload the page (methods exist for either get or post), during which the PHP code would need to processed.
Note: PHP/Webserver is server side which sends the page to the clients Browser. Once the browser has the page and the user can access it (example click on it) you are restricted to using client side techniques such as javascript unless you pass information back to the webserver/php again (form submit or via javascript ajax are two possible alternatives).
Posted: Thu May 10, 2007 9:39 am
by someguy4
well....
if you click on the text "bob" for example, it will run the function ChangeValues() that is specifyed in php
Posted: Thu May 10, 2007 11:16 am
by tvs008
you dont need to use javascript or ajax if you are ok with refreshing the page as usual.
Posted: Thu May 10, 2007 1:48 pm
by someguy4
trying to do this
Code: Select all
echo "<script type="text/javascript"><a onclick="ChangeValue()">clickhere</a></script>";
but get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
did i do it right?
Posted: Thu May 10, 2007 2:18 pm
by d3ad1ysp0rk
You REALLY need to step away from the editor and either buy a book or read an introduction tutorial on PHP. You're missing the concept of server side vs client side and what each is used for..
Posted: Thu May 10, 2007 2:22 pm
by someguy4
then can u tell me what i need to do to make this work?
Posted: Thu May 10, 2007 2:27 pm
by d3ad1ysp0rk
No. What you're proposing doesn't make sense. Like I said, start from the beginning, go read a beginner's tutorial.
Posted: Thu May 10, 2007 2:54 pm
by someguy4
alright fine