Reputation: 113
I am trying to click a link that was generated through PHP (I extracted the data and made them into strings). I would like to use part of the string incorporated into a link to execute another PHP script. My problem is I can not pass the variable to another PHP file by clicking on the link. NOTE: this code is between PHP tags. This works:
<a href=StandAloneRotate.php?bearingstate=TN>
This does not work:
<a href=StandAloneRotate.php?bearingstate=$State>
I guess my problem is incorrect syntax after the = sign. Any help would be appreciated.
Upvotes: 0
Views: 1146
Reputation: 1625
If you are echoing that through php you need to use double quotes to use the variable ...
also want to use double quotes around all html attributes to be in compliance with current standards ...
use the backslash to escape double quotes inside your PHP ...
so ...
<?php echo "<a href=\"StandAloneRotate.php?bearingstate=$State\">SomeLink</a>" ?>
Upvotes: 0
Reputation: 6919
Are you doing this through echo?
Some of the options are:
<a href=StandAloneRotate.php?bearingstate=<?php echo $State; ?>>
echo "<a href=StandAloneRotate.php?bearingstate={$State}>";
echo '<a href=StandAloneRotate.php?bearingstate='.$State.'">';
Upvotes: 0
Reputation: 5096
<? php
echo '<a href="StandAloneRotate.php?bearingstate='.$State.'">';
?>
Upvotes: 0
Reputation: 50966
echo '<a href="StandAloneRotate.php?bearingstate='.$State.'">';
if this won't work, try var_dump
var_dump($State);
Upvotes: 1