Jump to content

How to pass anchor name with paramaters in URL


worth2talk

Recommended Posts

Hi,

I have been struggling and googling since last 3 hours but didn't got any useful info yet. Well, my issue is i want to pass a parameter through URL along with anchor name. But i don't find anything to achieve this.

For example, i have two files as below:

 

test1.php

<?php
<a href = "test2.php#section1?sid=1"> Click </a> for section 1
<a href = "test2.php#section2?sid=2"> Click </a> for section 2
<a href = "test2.php#section3?sid=3"> Click </a> for section 3
?>

 

test2.php

<?php

$sid = $_GET['sid'];

echo " Section Id = $sid";
echo "<br />";

echo "<h2><a name=\"section1\">Section1</a></h2>";
echo " ..... some data ";

echo "<h2><a name=\"section2\">Section2</a></h2>";
echo " ..... some data ";

echo "<h2><a name=\"section3\">Section3</a></h2>";
echo " ..... some data ";
?>

 

But unfortunately, its not working...

 

can anyone have an idea to achieve this ??

 

Quick reply will be appreciated ...!!

 

Thanks in Advance ..!!

 

i think it might be because you have the #'s in the wrong place

 

<?php
<a href = "test2.php?sid=1#section1"> Click </a> for section 1
<a href = "test2.php?sid=2#section2"> Click </a> for section 2
<a href = "test2.php?sid=3#section3"> Click </a> for section 3
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.