<?php
function display($x){
//coding goes here.
}
?>
<html>
<body>
<p align="center">
<a href="what goes here?!">Display itmes</a>
</p>
</body>
</html>
| |
|
Welcome to KnowledgeSutra - Dear Guest | |
How To Use A Link To Call Function In Php?
#1
Posted 29 January 2006 - 02:37 PM
#2
Posted 29 January 2006 - 08:04 PM
#4
Posted 29 January 2006 - 10:45 PM
#5
Posted 29 January 2006 - 11:03 PM
fffanatics, on Jan 30 2006, 08:45 AM, said:
<?php
function display($x){
echo ($x - 10);
}
?>
No need for any session variables in there.
#6
Posted 30 January 2006 - 05:06 AM
fffanatics, on Jan 30 2006, 06:45 AM, said:
Can you give some sample coding here? I used a function because I don't want to redirect it to another page. The action is done in the function, in the page itself and not in another page. When I click the link, it should seem like nothing happened in the page but the function does its job.
#7
Posted 30 January 2006 - 03:43 PM
For example:
if( isset($_GET['function']) ) {
switch( $_GET['function'] ) {
case 'dosomething':
dosomething();
break;
case 'dosomethingelse':
dosomethingelse();
break;
}
}
And then link to script.php?function=dosomething
Hope that helps.
Oh, and Tyssen, using the link you originally supplied would cause nameOfYourFunction() to be executed whenever the script is, not just when the user clicks the link. Anything between <?php ?> (and, depending on server configurationm, <? ?>) is going to be processed as soon as the PHP engine encounters it within the script, so at the client's end, the link would end up pointing to whatever output nameOfYourFunction() returned (if any).
#9
Posted 06 May 2008 - 01:45 AM
How To Use A Link To Call Function In Php?
Hi, I've tried nearly everything on my script, my problem is that everytime I have the forma action (to get the isset($_get...) it reloads all my variables creating issues of course because I have two different forms. My script goes something like this (obviously I'm not applying syntax here):
Html:
Form action:process.Php method post
<input send>
<input preview>
No problems there.
Now the process.Php has several conditionals:
If(isset(send)){
SendFunction();
}
If(isset(preview)){
<input go back> this part works!
<input send> and here I need to use same function without resending everything
}
I can't use a form post in the last one because it'll process all script again. So I want to href link it to the function.
Please help!
-question by Taliaha
#10
Posted 08 August 2009 - 07:21 PM
Lol. Yeah, in case you haven't noticed, all PHP code never leaves the server. If you expect a browser to ever be able to interpret that, well, let's just put it this way: Browsers themselves don't ever see any php code, and therefore have no parsers/runtimes for such.
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users















