Anna Mereu
Anna Mereu

Reputation: 11

Problems with anchor tag - PHP

I wrote some code for a real estate website and I have a little problem.

When I click on an ad, I want to make the page go back at the line. In order to do that I use the anchor but it doesn't work.

In the main page I've put this

<a href="#<?php echo $do_query[id];?>"></a>

In the page of the ad detail I've put this:

<a  href="affitti.php?location=<?php echo $do_query[location];?>&&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >

It has to return at the number id of the anchor, but it doesn't go back either.

Can anyone help me?

Upvotes: 1

Views: 178

Answers (2)

Alex Andrei
Alex Andrei

Reputation: 7283

either use the name attribute as Marcos explains in his answer or an id see below

<a id="<?php echo $do_query[id];?>"></a>

and

<a href="affitti.php?location=<?php echo $do_query[location];?>&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >

the first placeholder needs to have an id set and the actual link will reference the placeholder by #id

Upvotes: 0

Marcos P&#233;rez Gude
Marcos P&#233;rez Gude

Reputation: 22158

It seems that you don't have the anchor per se. Check that is not missing:

 <a name="anchor"></a>
 <a href="#anchor">Click here to go anchor</a>

Upvotes: 3

Related Questions