Reputation: 75
So I have a dynamic PHP table where I am trying echo one of the table columns as a dynamically generated link. Presently, the $url variable i have declared is returning null. $row['username'] is returning what it should, so I suspect I have the syntax off for that. I also am having trouble with the syntax on the following line. How do I insert the $row['username'] as the link text?
echo "<td>" . "<a href='".$url."'> . $row['username'] . </a>" . "</td>";
this present example returns an error, but when I replace it with:
echo "<td>" . "<a href='".$url."'> blahblahfiller </a>" . "</td>";
the page runs, so I know it's my syntax there.
Here is my full code for the table:
<?php
while ($row = mysql_fetch_array($query)) {
$url = "profilepage.php?name=" + $row['username'];
echo "<tr>";
echo "<td>" . '<input type="checkbox" name="checkbox"/>' . "</td>";
echo "<td>" . "<a href='".$url."'> . $row['username'] . </a>" . "</td>";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $url . "</td>";
echo "</tr>";
}
?>
Sincere thanks for any and all help! It means a lot.
Upvotes: 0
Views: 414
Reputation: 31739
You are using +
instead of .
for to concatenate. It should be -
$url = "profilepage.php?name=". $row['username'];
Upvotes: 1