Reputation: 8818
I have a hyperlink <a href="<?php echo http://www.google.com?q=".$dynamicsearch; ?>" title="Link"></a>
that is on a cakephp view
.
When I click the link the $dynamicsearch
needs to be updated every time the link is clicked.
I tried to create a function in the cakephp controller
by calling the action generate_random_word
on the controller. When I click the link the controller would choose a random word on demand and then add it as the parameter and then redirect the url to open google in the browser with the random word.
I have tried many ways but have not found the solution. Any ideas!
Upvotes: 0
Views: 226
Reputation: 29121
I think you have a misconception of how PHP works in general. PHP generates the HTML, then it's done. It will not continue running methods after the page has been loaded completely.
What you'll need is some form of javascript if you want to edit the link on click, and ajax if you need to generate the word from the server.
The specifics of the code is beyond the scope of an answer on StackOverflow, but hopefully this will point you in the right direction.
Upvotes: 1