Hyperlinks within a table - ''.$row['username'].''

Taimur Source

I have made a leaderboard table on my site, which returns the users in the MySQL database with the highest scores (score is a separate field). The fields in the leaderboard table are 'rank' 'username' and 'score'. I would like to link each username in the table to it's own profile page.

The profile pages are in the format /profile.php?user=$username. How would I go about adding an <a href> within the table (which is echoed in php):

echo '<tr>
    <td>' .$a. '</td>
    <td><a href="profile.php?user=' .$row['username']. '">' .$row['username']. '</a></td>

I've tried the above, but it doesn't seem to work. It shows the usernames, but they don't have any hyperlinks.




answered 7 years ago Nanne #1

Looks correct to me. I would paste the (html) source-part it outputs, to get a hint what's really going on.

The retrieval part must be good, if you're seeing your usernames, so something strange is going on.

answered 7 years ago Etienne Marais #2


$row = array(
    'username' => 'Username',
    'count' => 5

echo '<table><tr><td>'
    . $a . '</td><td><a href="profile.php?user='
    . $row['username'] . '">'
    . $row['username'] . '</a></td><td>'
    . $row['count'] . '</td></tr></table>';


This works fine, I don't know what the problem is? I just do not know what $a does though

answered 5 years ago user2579195 #3


echo '<tr> <td>'. $ a. '</ Td> <td> <a href="profile.php?user=' .$row['username'].'">'. $ Row ['username']. . '</ A> </ td> <td>' $ row ['count'] '</ td> </ tr>'.;

is incorrect because of:

</ A>

Correct version is:

echo '<tr> <td>'. $ a. '</ Td> <td> <a href="profile.php?user=' .$row['username'].'">'. $ Row ['username']. . '</ a> </ td> <td>' $ row ['count'] '</ td> </ tr>'.;

comments powered by Disqus