href problem

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
daring1
Forum Newbie
Posts: 4
Joined: Tue Apr 03, 2007 8:21 pm

href problem

Post by daring1 »

Hi -

i have a main php page (mainpage.php) which loads another php page within it after clicking a link. (loadedpage.php).

My problem is all of the href links in the loadedpage.php are defaulting to the full url path of the parent page and then tacking the php variables i'm pulling in onto the end of it. In this occassion the variable being pulled from the database is the number 50.

So all of my anchor tags in the loadedpage.php which should just simply be: <a href=#50">, are now appearing as: <a href=http://myhomepage.com/mainpage.php?section=hottopics#50">.

All i want is the '#50'.

Here's an example of how the code looks: <a href="#<?=$htopicid?>">

Any help would be greatly appreciated....i just can't figure this out as to why it's doing it.

Thanks in advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you post a live link to this?
daring1
Forum Newbie
Posts: 4
Joined: Tue Apr 03, 2007 8:21 pm

Post by daring1 »

Hi feyd -

I PM'd the url to you...hope you don't mind...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<a href="#37">
ENCORE PALISADES</a>
</B></TD></TR><TR><TD style="font-size:10px;color:blue;"><B><a href="#40">
STATE OF THE TOWN-2007</a>
</B></TD></TR><TR><TD style="font-size:10px;color:blue;"><B><a href="#41">
Town of Haverstraw 2007 Summer Concert Series</a>
That's a copy directly from your page source. It's working correctly. What you are seeing is the browser's understanding of what the reference refers to.
daring1
Forum Newbie
Posts: 4
Joined: Tue Apr 03, 2007 8:21 pm

Post by daring1 »

I added the target to the href. i realized when i undid some attempts at trying to fix the problem that i went back to far and removed the target tag.

the problem is when you now click the link the entire page is loading into the iframe and not just jumping to the anchor tag.

sorry about that. thanks for checking into it though!
daring1
Forum Newbie
Posts: 4
Joined: Tue Apr 03, 2007 8:21 pm

Post by daring1 »

Fixed it. Turns out once you made me realize that the php was correct i knew there must've been something wrong with the actual link to the iframe which there was.

Here's how I corrected the problem:

<a href="hottopicscontent.php#<?=$htopicid?>" target="ifrm">

i needed to add the page name (hottopicscontent.php) of the iframe and then also target it. Works perfectly!

Thanks feyd for helping me figure this out! Much appreciated!
Post Reply