Forum Moderators: coopster

Message Too Old, No Replies

Linking Variables With Variable in link.

Im having some troubles with my links.

         

GamingLoft

3:18 am on Jul 28, 2007 (gmt 0)

10+ Year Member



Ok im having some trouble making this link work,

echo ("<a href=\"gamingrelated2.php?tid=" . $fid['$tid'] . "\">" . $fid['subject'] . "<A>");

Im sure it can load the data from mysql its just its not loading the integer after tid= (in the link)

[edited by: jatar_k at 3:24 am (utc) on July 28, 2007]
[edit reason] no urls thanks [/edit]

StudioKraft

3:25 am on Jul 28, 2007 (gmt 0)

10+ Year Member



Hello,

You shouldn't put variables within single quotes. Try:

echo '<a href="gamingrelated2.php?tid=' . $fid[$tid] . '">' . $fid['subject'] . '</a>';

Your second call to the array is correct to have the word "subject" in single quotes as you are referring to a defined key in the array. Having the variable in single quotes will cause PHP to accept it as literal and return nothing since there is no key in the array named "$tid".

Also, using single quotes in the echo statement removes the need to escape the double quotes.

Hope this helps,

SK

GamingLoft

4:33 am on Jul 28, 2007 (gmt 0)

10+ Year Member



i just realized the problem there shouldn't be a $ beside tid.

but ill try your script too.

and the things are in single quotations because there rows.

Edit:

Yep used your line of code its working great now, thank you very much.

[edited by: GamingLoft at 4:35 am (utc) on July 28, 2007]