TinyPortal
Development => Support => Topic started by: pheasant_plucker on August 20, 2009, 08:44:11 AM
Is it possible to have a link in a php block refer to the block it's in? I want to have a clickable link which changes a database field depending on the information sent in the header with the link. I can do this by sending the information to a seperate script but I wondered if linking to the same script is possible.
Gerry
do you mean read a value out of the url.. i.e. by using $_REQUEST
or read a value sent from a form.... i.e. by using $_POST
I have used both within a php article, can't see why a php block shouldn't be able to grab the same information as it's all parsed into the same page.
I was using $_GET but what would the href be to link back to itself?
Gerry
for my php article i link back to index.php?page=XXXX
for a block presumably linking back to any page that will contain that block would work ...?
i'm guessing though.
Quotefor a block presumably linking back to any page that will contain that block would work ...?
Yes.
I use this in a block:
$str = getenv("QUERY_STRING");
if ($str)
$action = 'index.php?'.$str;
else
$action = 'index.php';
This uses a form and not a link of course, but it's the same idea. The
getenv("QUERY_STRING") returns whatever is after the ? in a url (if anything) so that the user will go back to the place where they were, once the link is clicked.
Thanks for the help. JP's solution is just what I need.
Gerry
Will mark this to solved then :up: