How to set and get values from an url
I would like to set values on an url like this:
<a href='http://$data_url/viewyournote.php?chapter='$name_of_chapter'¬e='$id_note'&user='$username'>
Then be able to grab then from the recieving page.
开发者_如何学JAVARight now all im getting is this when clicked:
http://localhost/readnotes/viewyournote.php?chapter=
I don't how you embed your link in your code, but if it is outside of <?php ?>
tags, then you have to do:
<a href="http://<?php echo $data_url ?>/viewyournote.php?chapter=<?php echo $name_of_chapter ?>¬e=<?php echo $id_note ?>&user=<?php echo $username?>" >
if it is inside these tags, you can also do:
echo "<a href='http://$data_url/viewyournote.php?chapter=$name_of_chapter¬e=$id_note&user=$username?' >";
You can get these values on the recieveing page with $_GET['variable_name_here']
, e.g. $_GET['chapter']
.
Use Query string
$val = "yourvalue" ;
$url "http://localhost/readnotes/viewyournote.php?chapter=$val";
Now $val is passed to specified url .
There you could get it by using $_GET['chapter'] , It will give you "yourvalue"
<a href='http://$data_url/viewyournote.php?chapter=<?php echo $name_of_chapter; ?>¬e=<?php echo $id_note; ?>&user=<?php echo $username; ?>>
Replace your line with
<?php
echo "<a href='http://$data_url/viewyournote.php?chapter='$name_of_chapter'¬e='$id_note' user='$username'>";
?>
On the receiving end use
<?php
$name_of_chapter = $_GET['chapter'];
...
?>
精彩评论