Jump to content

Recommended Posts

Can someone please help me!!

 

How can I get the value in an link like

 

<a href="#first">Link</a>

 

I need to get first in an variable.

 

I have search an search but I can't find any help. I know I can get it if i pass it in the URL name but the way the css is coded. I need to get the value like it is.

 

 

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/302290-get-value-posted-in-url/
Share on other sites

If you are looking to pass variables through anchor tags, you use a format like this:

<a href="?myVar=hello">Link</a>

Note the question mark before the variable named "myVar". When you click the link, the variable is passed to PHP and can be retrieved using $_GET['myVar']. Here's a quick code sample that you could use:

<?php
if(isset($_GET['myVar'])) {
    echo $_GET['myVar'];
}
?>
<div><a href="?myVar=hello">Link</a></div>
  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.