Anchor Tag Help W/PHP

Jul 16, 2005

I'm using PHP and while this is an HTML question, I'm looking for a
PHP answer please - I've got several anchors similar to the one shown
below - I'm calling a dispatcher.php script and I need to be able to
determine which anchor was clicked on even tho they will all call the
same dispatcher.php script - in PHP can I detect which anchor was
clicked on once I'm in the dispatcher script?

<A HREF="dispatcher.php">2</A>


Anchor Tag And SERVER_ROOT In Anchor Tags?

Nov 18, 2009

website, and I am confused on what to do about SERVER_ROOT in my anchor tags.Right now my index page looks like:
$server = preg_replace('/(.+\/).+\..+/', "$1", $_SERVER['SERVER_ROOT']);


The file loads fine, however the links aren't working.The url becomes:


What I want is to have it just be:


I wish to correct the anchor tag problem.

View 6 Replies View Related

If Anchor Is Clicked / Echo Information On A Page After And Anchor Has Been Clicked?

Mar 19, 2011

I'm trying to echo information on a page after and anchor has been clicked

<a id="anchor">Information</a>

View 7 Replies View Related

Set A Var To #anchor Value?

Feb 20, 2011

Is it possible to use #anchors to set a variable in PHP?

For instance if I the url was

have $location = flash
Here is my code so far..
<script type="text/javascript">{
content:    '<div id="<?php echo "$location" ?>
">Welcome to my website!</div>',


View 3 Replies View Related

Redirect With Anchor Tag In IE

Jul 17, 2005

The following PHP code snippet works in Firefox and Opera but NOT
Internet Explorer (I'm using IE v 6.0.2xxx)

$url =
header("Location: " . $url); /* Redirect browser */

The Anchor Tag: "#AT2" generates a 505 error in Explorer. When the
Anchor Tag [#AT2] is removed from the URL everything works fine.
Any thoughts on a workaround?

View 9 Replies View Related

Anchor Position

Jul 17, 2005

Could anyone teach me how to set anchor for a php link?

Is the following right?

Or the following?

Or both are wrong?

Besides, could I go to anchor position by PHP command?

View 1 Replies View Related

Extracting Anchor From Url

Jun 23, 2005

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

<a name="tag1">
some text
<a name="tag2">
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: <a href="page.php#tag1">
We just go to the tag. But for Code:

View 2 Replies View Related

Getting Anchor Name With Regex?

Nov 15, 2010

I need to capture the name of an anchor html tag with regex and php so from text I will get "hello" (the name of the anchor)

Tried that:

$regex = '/(?<=name=")#([^]+?)#(?=")/i';
preg_match_all($regex, $content, $data);

I've tailed the apache error log to find out that:

PHP Warning: preg_match_all(): Compilation failed: missing terminating ] for character class at offset 26

also tried:

$regex = '/(?<=name=")([^]+?)(?=")/i';
$regex = '/(?<=name=")[^]+?(?=")/i';

which are basically the same. I guess I'm missing something, probably a silly slash or something like that but I'm not sure as to what

View 4 Replies View Related

Linking To A Named Anchor

Sep 26, 2002

I've got a PHP script for a very basic CMS which links a page to itself when a "Submit" button is clicked in a form, at the same time a variable "Number" is sent, telling the script which particular "Submit" button was clicked. The following script takes place in a PHP loop using the counting variable $i: Code:

View 4 Replies View Related

Anchor Tags And PHPSESSID

Mar 3, 2003

Trying to pass anchor tags and the PHPSESSID together.

echo "<a href=page.phtml#".$classinfo2["cla_ins_id"]."?$sUrlSession>"

The only browser this works in is NS 4.79

View 2 Replies View Related

Jumping To Anchor After Submit

Jul 17, 2005

i have a form with lots of data, and when they click on a button it
calls some javascript which sets values in hidden fields then posts to
itself (usual stuff)

now the problem is that i would like to bring the page back to the
same spot after the submit (as its very long)

Ive added anchors to each button but if i add a the anchor tag to the
action part of the form, im always one click behind, ie it jumps to
the one I clicked on before. ive tried using location header etc
calling itself and appending #anchorname to the end of the url, but
then i lose the data in the form, as no $_requests have data any more.

so what i need is when you hit a button, sumit the page && go to the
correct anchor. is this possible

View 7 Replies View Related

Preg_replace - Replace Something With An Anchor Tag

Jul 17, 2005

I dont think I'll ever understand regular expressions ... I need to do th
efollowing and I just don't know where to start:

$haystack = "How much wood would a wood chuck chuck if a woodchuck could
chuck wood?";
$needles = ("wood","chuck","wood chuck");

I want to replace every needle with an anchor tag like this:

<a href="def.html?word=wood">wood</a>
<a href="def.html?word=chuck">chuck</a>
<a href="def.html?word=wood%20chuck">wood chuck</a>

How do I do this?

View 4 Replies View Related

Anchor And Form Submit

Oct 3, 2004

I need an anchor on a form action to get my page to locate properly in the browser. (I do a select lookup and propogate another select). Now that I have added the anchor:

my form only reloads and doesn't perform the right action:

is not working properly with the anchor. Does someone know how to work with anchors and not mess up the php?

View 1 Replies View Related

Dynamic Anchor Based On Last Name

Apr 5, 2004

I have a MySQL database that hold the list of employees. I display the page using PHP. All of this works great, I sort by last name ascending so the list is A-Z.

Here is what I want to do.

At the top of the page I want to list each letter of the alphabet and have it as a link. From that link (lets say "G") when I click on G it jumps to the first employee that has a last name that starts with G (staying on the same page)

Is there some way to create a dynamic anchor that would jump to a specific areas based on how the alphabet link was coded?

View 1 Replies View Related

Get Href From Anchor Tag With Particular Class?

Jul 12, 2010

If I have an HTML document, what is the best way to go through the document and gather the href values from all anchor tags with a particular class using PHP?

View 4 Replies View Related

Regular Expression Anchor Tag?

Jul 29, 2010

i am using php and i am having problem to parse the href from anchor tag with text.

example: anchor tag having test http:/[url.....

like this <a href="http:[url]....

i want to match all text in anchor tag

View 3 Replies View Related

Obtain Anchor Part Of URL After # ?

Jun 23, 2009

While using LightBox mechanism in my project I got an URL


I need to collect that patientid from this through GET mechanism, Is that possible in PHP?

View 4 Replies View Related

SELECT Statement In Anchor Tag?

Dec 3, 2010

page where it displays URLS, tags, and the user associated with it who is logged in after a login form was done.The tags are hyperlinks, so if a user clicks on it, it will reload the page with all the URLs associated with that tag.Im working from a database, so can i use a select statement within the anchor tag to achieve my task?

View 3 Replies View Related

Add Anchor Tag When It Add Products During Execution Or Run?

Mar 16, 2010

below code is creating menu like this shown about.the only one thing i need to have is that i want to put <anchor tag when it add products during execution or product4 should be in anchor tag etc.
global $menu_array;
running query
$result = mysql_query("SELECT * FROM `tblcatagory`");

fetch rows to show like tree
while ( $row = mysql_fetch_assoc($result) )
$menu_array[$row['cat_id']] = array('Categoryid'=> $row['cat_id'],'name' => $row['cat_name'],'parent' => $row['parent']);
recursive function that prints categories as a nested html unorderd list
function generate_menu($parent)
$has_childs = false;
this prevents printing 'ul' if we don't have subcategories for this category make array global
global $menu_array;
use global array variable instead of a local variable to lower stack memory requierment
foreach($menu_array as $key => $value) {
if ($value['parent'] == $parent)
{ if this is the first child print '<ul>' if ($has_childs === false) {
don't print '<ul>' multiple


MySQL Data Transfer, Source Host: localhost, Source Database: sre, Target Host:localhost, Target Database: sre, Date: 3/16/2010 2:08:56 PM */
-- ----------------------------
-- Table structure for tblcatagory
-- ----------------------------
CREATE TABLE `tblcatagory` (
`cat_id` int(10) NOT NULL AUTO_INCREMENT,
`parent` int(10) DEFAULT NULL,
`cat_name` varchar(255) DEFAULT NULL,


View 1 Replies View Related

Get Anchor Tag Text Using Javascript?

Jul 13, 2010

invoke a search corresponding to all links in my Wordpress blog.I am using an Ajax call for my other search in this site.How can I retrieve a linking text from hypertext tag in html.


here i want to get 'demo' as input.

View 2 Replies View Related

Get An Anchor Tag To Delete A Session?

Nov 21, 2010

I need to get an anchor tag to delete a session in php + log the user out of Facebook. Before I used Facebook connect, I was using this php code to destroy the session:

$_SESSION = array();
header("Location: /");

And this for the anchor tag:

<a href='?logoff'>Log Out</a>

I now need the same anchor tag to go to the $logoutUrl + destroy the session.

View 1 Replies View Related

Test If An Anchor In URL Exists And To Get Its Value

Oct 30, 2010

I was wondering how to test for an anchor in the URL and to get its value.

Most URLs look something like this:


But sometimes an anchor is appended to the URL:


The reason I am asking is because on my forum I want members to be able to send links to posts. To be able to do that, I need to send an anchor. However, the issue lies in that members may have different display settings so they'll be displaying a different number of posts per page than perhaps the person sending the link.

If the link sent is to the 21st post, but the person receiving it is displaying 20 posts per page, then it would be on the second page.

What I am looking to achieve is:

1) Test for an anchor's presence. If it's not there then don't worry about it.
2) If it's there, get its value and determine which post it is.
3) Once the post is determined, determine which page the post is on.
4) Once that is determined, direct the user there.

Unless there's a completely different (and easier) method of doing this.

View 6 Replies View Related

Capturing The #anchor String?

Sep 4, 2009

I just realized, after doing a var_dump call on the $_SERVER variable, that when a php page is accessed with an anchor value, the PHP script cannot get the #anchor data.

Is there anyway to get the anchor data in PHP?

View 1 Replies View Related

Add Anchor Tag To URL From Text Input?

Dec 24, 2009

I want to be able to take user inputted text in a comment field and check for URL type expression, and if it exists, add an anchor tag (to url) when the comment is displayed.

I am using PHP on the server-side, and Javascript (with jQuery) on client, so should I wait to check for URL until right before it is displayed? Or add the anchor tag before inserting it in the database?


<textarea id="comment">check out or or</textarea>


<div id="commentDisplay">check out <a href=""></a> or <a href=""></a> or <a href=""></a></div>

View 4 Replies View Related

Get Anchor Text Using DomDocument?

Jan 7, 2011

Say I have this html:

<a href="">Test</a>

I parse it using dom document with this code:

$dom = new DomDocument();
$urls = $dom->getElementsByTagName('a');

And then I run this code:

foreach ($urls as $url)
//echo "<br> {$url->getAttribute('href')} , {$url->getAttribute('title')}";
foreach ($url->attributes as $a)
echo "<br>$a->name is $a->value";
echo "<hr><br>";

When I do this, I only see 'href' as an attribute of the url, there's no way to get the 'anchor text' (in the above case 'Test'). How can I get the anchor text of the link?

View 3 Replies View Related

Extract The Anchor Text From The RSS?

Aug 17, 2010

I tired all my PHP skills to extract domain name strings from a RSS Feed and put each domain name as an array element, but all in vain:Here is the RSS: [URL}....Do you see a list of domain names, which are anchored? All I need is to extract these domain names like " uk", (there is a space between .co and .uk), which can beremoved with str_replace).Here is my first try: (Using SimpleHTMLDomParser)

$html = file_get_html('');
$domains = $html->find('div[class="entry"] a', 0);

View 1 Replies View Related

Go To Anchor Without Refreshing Page?

Mar 31, 2009

I have been using ajax (prototype) to generate a table with values from a mysql database. I have a administration page where someone can delete an entry. I have the script re-generate the table once someone has deleted an entry. I setup anchors into each table row and I want the page to go to the next row down. I have tried to do that but each time I try with javascript, it refreshes the page.

View 1 Replies View Related

Anchor Tag In FF; Targeting Hidden Div?

Mar 8, 2011

I'm having an issue with Firefox and anchor links from an external page to a tab div on the landing page; while IE render these correctly (I know, that means little), FF and Chrome both send the user to a place somewhat above or below the actual anchor tag. I didn't write the original code, but I'm not able to find much about a FF bug that would cause this, or a solution?

View 2 Replies View Related

Extracting The Anchor Text From The RSS

May 29, 2011

I tired all my PHP skills to extract domain name strings from a RSS Feed and put each domain name as an array element, but all in vain: Here is the RSS: [URL] Do you see a list of domain names, which are anchored? All I need is to extract these domain names like " uk", (there is a space between .co and .uk), which can be removed with str_replace). Here is my first try: (Using SimpleHTMLDomParser)

$html = file_get_html('');
$domains = $html->find('div[class="entry"] a', 0);
foreach($domains as $dom)
echo str_replace(' ', '.', $dom->plaintext);

Here is my another try with DOM Document:


In both the cases, DOMDocument is created but it seems the Document has all information except the domain names I want to extract.

View 1 Replies View Related

Query With Anchor Tag In Mysql?

Dec 11, 2010

If i click on city link give data order by city.same for username


View 1 Replies View Related

Pull Information Off An Anchor ID

Jul 18, 2007

I have a bunch of links that ref is the same page.  Is there any way on that second page I can tell which link was clicked if my links are structured as:

<a href="page.php" id="link1">Link 1</a>
<a href="page.php" id="link2">Link 2</a>
<a href="page.php" id="link3">Link 3</a>
<a href="page.php" id="link4">Link 4</a>

View 7 Replies View Related

Anchor Tag File In The Folder?

Jan 5, 2010

actually i backup my database using php script, that stores the sql file in the folder.Now i want to take make a "button", when i clicked on it the SQL file has to be opened.

View 1 Replies View Related

Getting The ShortName Variable In The Anchor Tag?

May 18, 2011

What I'm want to know is either a better way to write this or find out what I'm doing because its not getting the shortName variable in the anchor tag.

Code: [Select]function spotlight(){
$query = "
characters.statusID = 1 AND characters.styleID = 1


View 6 Replies View Related

Tracking The Clicked Anchor Text

Dec 1, 2004

I want to fetch the anchor text clicked by a user. Can it done with php.

Deailed description: I want to create a dictionary kind of thing. Every word in the paragraph will have a link and a value which will be the cliked word will be passed to the next page that will fetch the meaning of that word from the database.

View 1 Replies View Related

Execute A Windows Program From An Anchor Tag

Jul 17, 2005

I believe I am close but I have spent several hours investigating this and
can't understand why it won't work. I have tried exec, system, and settled
on popen from reading various notes on the subject. I am wanting to launch
a file editor when I click on a link. This is strictly an internal
application so I don't need to worry about escaping shell/args. This is
what seems as if it should work, however it doesn't. This is on XP, latest
Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
exists. Thanks.

if (chdir("C:Program FilesTextPad 4")) {
$cmd = "start "textpad.exe" x:webprogram.php";
pclose(popen($cmd, "r"));

View 11 Replies View Related

Eregi (html Anchor Tags)

Jun 11, 2003

I need to get all the html anchor tags from a string. heres my eregi line: PHP Code:

View 1 Replies View Related

Change The Color Of An Text Anchor

Oct 15, 2001

Rollovers that work. I'm looking for at class that will let me change the color of an text anchor <a> when I move the mouse over an image. So far I have only been able to find some horrible Java-script examples. IE is easy enough but Netscape seems to be a pain in the a.. when it comes to rollovers.

View 5 Replies View Related

Anchor In URL When Using Symfony's Redirect Function?

Apr 17, 2011

I'm using

$this->redirect('route', array('id' => $id));

but I need to be able to put "#" anchor at the end but I can't find a way of doing that.

The code

$this->redirect('route', array('id' => $id));

returns /route/id/5 but I want to be able to create /route/id/5#anchor7

View 1 Replies View Related

Preg_match To Extract Mailto On Anchor?

Nov 23, 2010

I need to get the email adress from an anchor with a mailto attribute with regex.

this pattern: (.*)<as(.*?)(.*)s*href=['"]mailto:([-a-z0-9_]+)@([a-z0-9-]+).([a-z]+)['"]>(.*)</a>(.*)

Works in regex coach though it doesnt work with PHP.


preg_match("'(.*)<a (.*?)(.*) *href=['"]mailto:([-a-z0-9_]+)@([a-z0-9-]+).([a-z]+)['"]>(.*)</a>(.*)'si", "<a href=""">Some email</a>", $matches);

So why doenst it work in php?

View 3 Replies View Related

Make An Anchor Tag Not Go To A URL/Open A File?

Dec 1, 2010

I basically have a webpage with two frames.

-Left for nav
-Right for main content. I have a text-box here called "file_path"

Currently, I have a list of files on the left hand side that I am displaying as anchors. I want the functionality that if the user clicks a file on the left hand frame, I can grab the value and put it in the text-box on the right hand frame. I able to do this successfully, but the problem is that after getting the value in the right frame, my left-frame opens the file in that section ... I want to prevent the file from being open. I only want it to pass the value there.

echo "<li><a href=".$filepath." onClick="parent.right.document.getElementById('file_path').value='$filepath'">$filepath</a></li>";

I tried merely putting the onClick for the list item, but this way I loose functionality, so that the user feels that the link is clickable. It just appears as static text ... I'd rather have the cursor change when the user goes on it like an anchor tag, but just not open the file ...

echo "<li onClick="parent.right.document.getElementById('file_path').value='$filepath'">$filepath</li>";

View 3 Replies View Related

Jump To Named Anchor With Javascript

Apr 7, 2011

I have a php (codeigniter) program that displays all the finished projects of and engineering company. I can click the detail page and from there I can click a link to go back to the overview page. To avoid starting at the top of the list again I would like to jump to the project I cam from. It seems easy but it gives me problems. I found this solution on the Internet that works with Chrome but not with Firefox and IE

function moveWindow (){window.location.hash="a13";}

the content of the anchor gets dynamically generated by PHP. As I sail works in Chrome only. IE says something like undefined function moveWindow when I go in in debug mode.

View 1 Replies View Related

Header Location Redirect With Anchor Tag And IE7?

Jun 8, 2009

Here is my issue, it could just be a browser issue but any help/ideas would be awesome!Pretty much I have the following redirect:header("Location: page.php#images");In most modern browsers it will redirect to page.php#images without any problems but in IE it seems to strip the #images. Has anyone come across this? So far my only option (which I think is a terrible option) is to redirect through JavaScript.UPDATE
I sent up a simple sandbox and it seems to work fine with or without an absolute URL. I guess there is something else going on in my actual app that is conflicting with it. I'll update when I figure it out, thanks for all the responses!

View 2 Replies View Related

Regex/preg_replace Be Used To Add An Anchor Tag To A Keyword?

Jan 3, 2009

I would like to be able to switch this...My sample [a id="keyword" href="someURLkeyword"] test keyword test[/a] link this keyword here.

To...My sample [a id="keyword" href="someURLkeyword"] test keyword test[/a] link this [a href="url"]keyword[/a] here.I can't simply replace all instances of "keyword" because some are used in or within an existing anchor tag.

Note: Using PHP5 preg_replace on Linux.

View 2 Replies View Related

Newline In Body Of Mailto Anchor?

Dec 10, 2010

I am looking to create a message with several lines, but when I put my string into the mailto statement I can't find a newline character that works.

$MESSAGE_BODY .= "Message: " . nl2br($_POST["message"]) . "

View 1 Replies View Related

Html - Calling A Function Within An <a > Tag, Anchor Tag?

May 6, 2010

Is it possible to call a PHP function within an anchor tag.I have a PHP function called logout();
Now I want something similar to this.
<a href="logout();" >Logout</a>
I know with Javascript this works but what is the best approach using PHP function?

View 3 Replies View Related