dynamic named anchor syntax

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 30, 2009   (RSS)

By rez - November 30, 2009

Please show me how to make a dynamic anchor, already within the php tags. [crazy]

<?php
echo "<a name=\"$record['num']\" id=\"$record['num']\"></a>";
?>

Re: [rez] dynamic named anchor syntax

By Chris - November 30, 2009

Hi rez,

I'm a little confused, it seems like you answered your own question! Did that not work for you?

P.S. The id="" isn't necessary; the name="" is what's required for an anchor.
All the best,
Chris

Re: [chris] dynamic named anchor syntax

By rez - November 30, 2009

I tried variations. But kept getting:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in


So the code looks right, huh? I'll get to a computer and try without the ID but I tried the above. There error points to that line and without that line, the page is fine. Hmmm

Re: [rez] dynamic named anchor syntax

By rez - November 30, 2009 - edited: December 1, 2009

Still getting the error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

The code I tried is:
<?php

echo "<a name=\"$record['num']\"></a>";
?>