TinyPortal

Development => Support => Topic started by: pheasant_plucker on August 20, 2009, 08:44:11 AM

Title: hyperinking a PHP block back to itself?
Post 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
Title: Re: hyperinking a PHP block back to itself?
Post by: ed_m2 on August 20, 2009, 08:55:25 AM
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.
Title: Re: hyperinking a PHP block back to itself?
Post by: pheasant_plucker on August 20, 2009, 08:58:32 AM
I was using $_GET but what would the href be to link back to itself?

Gerry
Title: Re: hyperinking a PHP block back to itself?
Post by: ed_m2 on August 20, 2009, 11:04:14 AM
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.
Title: Re: hyperinking a PHP block back to itself?
Post by: JPDeni on August 20, 2009, 01:10:50 PM
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.
Title: Re: hyperinking a PHP block back to itself?
Post by: pheasant_plucker on August 20, 2009, 03:21:05 PM
Thanks for the help. JP's solution is just what I need.

Gerry
Title: Re: hyperinking a PHP block back to itself?
Post by: G6Cad on August 21, 2009, 07:36:31 AM
Will mark this to solved then  :up: