Page 1 of 1

Make a link carry a variable without forms

Posted: Mon Aug 07, 2006 5:58 pm
by ibanez270dx
Hi,
Just a quick question: How do I have a link (a simple "a href" deal) that carries on variables? More speicifically, my problem arises when I want my HTML link to load the page again and goto an isset thing in the PHP. Here is currently what I have, which doesn't work:

Code: Select all

if(isset($_POST['2excel']))
 {

blah blah blah

<td>
<a href="<?= $_SERVER['PHP_SELF'] ?>" name="2excel" class="print"><img src="images/excel.gif" border="0"> <b>Export to Excel</b></a>
</td>
Any suggestions? I don't want to have to use forms...

Thanks,
- Jeff

Posted: Mon Aug 07, 2006 5:59 pm
by Luke
$_GET

Posted: Mon Aug 07, 2006 6:14 pm
by ibanez270dx
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


ok, so now I have:

Code: Select all

if(isset($_GET['2excel']))
 {

$test = "if I can see this, it works";

 }

blah blah blah

<td>
<a href="<?= $_SERVER['PHP_SELF'] ?>" name="2excel" class="print"><img src="images/excel.gif" border="0"> <b>Export to Excel</b></a>
</td>

<? echo "$test"; ?>
This doesn't work... anything missing?


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Aug 07, 2006 7:14 pm
by RobertGonzalez

Code: Select all

<?php
$test = 'Click here to check if we used GET';
$back = '';

if ( isset($_GET['test']) )
{
    $test = 'Yep, we used get!';
    $back = '<a href="' . $_SERVER['SCRIPT_FILENAME'] . '">Go back to the original</a>';
}

echo '<a href="?test=1">' . $test . '</a>';
echo "\n<br />\n";
echo $back;
?>