Co1eK Co1eK - 2 months ago 4x
HTML Question

PHP/HTML ~> href link from mysql fetch

Im trying to set up some text that links to the url column of the row for each item in the table. I tried the below which does not work at all and just gives me a white screen.

echo "<br><a href=\"$row["pageLINK"]\">". $row["pageNAME"]. "</a><br>";

But on the other hand, the code below works just fine.

echo "<br><a href=\"\">". $row["pageNAME"]. "</a><br>";

It might be something very simple but I'm just getting into php so any kind of help would be appreciated.


You can't use quotes inside an echo when referencing an array index.

This line:

echo "<br><a href=\"$row["pageLINK"]\">". $row["pageNAME"]. "</a><br>";

Should be this:

echo "<br><a href='$row[pageLINK]'> $row[pageNAME]</a><br>";

Or you could do using quotes and brackets, like in e4c5's answer.