tet3828 Posted December 20, 2006 Share Posted December 20, 2006 Is it possible to use a <a href> link to perform a function within the document? (ie [PHP_SELF})I also need to pass thes varibles onto the function:?action=add&id=".$row['itemId']." Link to comment https://forums.phpfreaks.com/topic/31420-solved-href-to-permform-a-function/ Share on other sites More sharing options...
c4onastick Posted December 20, 2006 Share Posted December 20, 2006 Yep. But not the way I think you're thinking about it. Usually when I have to do things like this, I use:[code]<a href='example.php?action=update&id=12'>Click Here</a>[/code] But you're going to have to build the links into the page with php like so:[code]while($res->fetchInto($row)) // Read rows from PEAR DB call{ echo '<a href=\'example.php?action=update&id='.$row[0].'\'>'.$row[1].'</a>';}[/code]Where $row[0] is your id from the database, and $row[1] is a title or name or whatever. Corresponding to a SQL something like:[code]SELECT id, title FROM mytable[/code]Then in your example.php script, you can process that info however you want, and throw a header redirect at the end to take you back to the page that submitted it or wherever else you want to go.[code]header("Location: formfillout.php");[/code]Actually now that I think about it, you could have all the code that handles the updates or whatever on the same page, just using the same page in the 'a href'. In that case I'd clear the $_GET variables after processing them before proceeding with the rest of the code so that you don't get weird errors with page refreshes. Link to comment https://forums.phpfreaks.com/topic/31420-solved-href-to-permform-a-function/#findComment-145461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.