How to know whether i have clicked the particular link in the next page
I have created certain links using a for
loop in PHP.
foreach($storage as $val)
{
if($val!="")
{
echo "$val";
echo "<a href=\"b.html\">Link</a>";
}
}
Page will look lik开发者_开发知识库e
content1 Link to b.html
content2 Link to b.html
content3 Link to b.html
content4 Link to b.html
...
...
In the next page I want to retrieve the correct content based on the link clicked. Example: If I click the second link the content to be retrieved is "content2".
How can I accomplish this?
Create your links like that:
echo '<a href="b.html?content=' . $val . '">Link</a>'
Then, on the other page, use this code:
$content = isset($_GET['content']) ? $_GET['content'] : '';
Then $content
contains whatever was passed in the URL - or an empty string if the param was missing.
You could set Get parameters so that your links are to b.html?var=content2
Then you can just read the Get Parameters
echo $val ."<a href=\"b.html?var=". $val ."\">Link</a>";
and you can then view this value with
echo $_GET['var'];
精彩评论