0

I need add a named anchor into this code:

<?
echo "<a href=\"reviews-mockup2.php?category=$category&amp;keyword=" . $_REQUEST['keyword'] . "&amp;nationalpage=";
?>

which currently looks like this in the page:

http://test.usfamilyguide.com/reviews-mockup2.php?category=&keyword=&nationalpage=1

I tried

<?
     echo "<a href=\"reviews-mockup2.php?category=$category&amp;keyword=" . $_REQUEST['keyword'] . "&amp;nationalpage=" . "#named-anchor";
?>

and got

http://test.usfamilyguide.com/reviews-mockup2.php?category=&keyword=&nationalpage=#named-anchor1

thanks!

bluedimensional
  • 346
  • 1
  • 3
  • 17

1 Answers1

0

Your anchor <a> tags seem to have an incorrect syntax. Refer to W3Schools.

Assuming, you are wanting it to jump to a particular section in a page; your solution should be something like this:

echo "<a href='reviews-mockup2.php?category={$category}&amp;keyword={$_REQUEST['keyword']}#named-anchor'>Your Anchor Name</a>";

What I did was: removed the nationalpage as I assumed thats what you were using to anchor to sections in the page, put all the PHP in curly braces {} and finally fixed your tag syntax as defined in the link I gave earlier. This should work to how you expect.

Any issues let me know.

Lachie
  • 1,321
  • 1
  • 10
  • 26