Extracting anchor from url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hessodreamy
Forum Commoner
Posts: 58
Joined: Wed Apr 20, 2005 8:11 am

Extracting anchor from url

Post by hessodreamy »

I have a page with a bunch of anchor tags. eg:

Code: Select all

<a name=&quote;tag1&quote;>
some text
<a name=&quote;tag2&quote;>
some more text
(In case you didn't know what anchor tags looked like!)

What I want to do is write to the database when a particular anchor is requested. So for

Code: Select all

<a href=&quote;page.php#tag1&quote;>
We just go to the tag. But for

Code: Select all

<a href=&quote;page.php#tag2&quote;>
We write to the database as well.

How do I do this? The # in the url doesn't seem to be available to $_REQUEST and suchlike, nor to the $_SERVER variables.
Any ideas?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Isn't it supposed to use id rather than name ?

Code: Select all

<a id=&quote;tag1&quote;>some text</a>
<a id=&quote;tag2&quote;>some more text</a>
Anyways my understanding that a page request to the server is not sent to the db with a # link. As such there is not way to do it using a pure PHP method. You may want to add javascript and possible use the HttpRequest methodology as described in Burrito's XMLHttp tutorial (who's online example)topic
Post Reply