Jump to content

[SOLVED] Linking to a function in PHP


rascle

Recommended Posts

Browsers can only make http requests to web servers. A link is only a URL that gets requested when that link is clicked. The code on the page that is the target of your link would need to execute the php code you want. If you want more than one action on that page you will need to use a GET parameter on the end of the url that identifies what action you want to perform in the code on that page and your code will need to test what the GET parameter is (a SWITCH/CASE statement would be the most general purpose way of testing for multiple action values.)

Link to comment
Share on other sites

What i mean is with like Javascript if you have a function:

<script type="text/javascript">

function goto(){

window.status = www.rasclerhys.com

}

</script>

<a href="#Javascript:goto()">

^ the code above may be wrong but you get the point.

I want to do the same in PHP for example if you have a page that shows results from a MySQL DB and you have a function that creates a MySQL Query deleting the results in the table and you want to have a link so when the user clicks the link saying "Delete Results" it will run the function and then the results will be deleted. < Just an example.

Thanks

Link to comment
Share on other sites

php basics 101:

 

php.. is a server side language.. meaning whatever happens on the server side (much like vegas) stays on the server side..

 

what is recieved by the client (web browser) is html or plain text, output by php.

 

php can not run active with the client, once data gets output, php exits, and the browser handles the html/css/javascript..

 

what you can do is link to a javascript function..

 

which connects to aphp page via AJAX

 

then does the actions you wanted php to do..

 

but you can not link directly to a specific php function unless you make a file with a bunch of functions, and send the function name via get then do

 

$_GET['functionName'](arguements here);

^^ dunno if that'd work..

 

if not try

 

$function = $_GET['functionName'];

$function(arguements here);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.