Make a link carry a variable without forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Make a link carry a variable without forms

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

$_GET
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Post 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]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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;
?>
Post Reply