表中的超链接 - '< a href ="">'。$ row ['username']。'< / a>' [英] Hyperlinks within a table - '<a href="">'.$row['username'].'</a>'
问题描述
我在我的网站上制作了一个排行榜表格,它返回MySQL数据库中分数最高的用户(分数是一个单独的字段)。排行榜表格中的字段为'排名''用户名'和'分数'。我想将表格中的每个用户名连接到它自己的个人资料页面。
个人资料页面的格式为 /profile.php?user=$username 。我该如何在表格中添加一个< a href>
(这在php中回显):
echo'< tr>
< td>'。$ a。 < / TD>
< td>< a href =profile.php?user ='。$ row ['username']。'>'。$ row ['username']。 < / A>< / TD>
< td>'。$ row ['count']。'< / td>
< / tr>';
我已经尝试了上述内容,但似乎无法工作。它显示用户名,但他们没有任何超链接。
谢谢
<?php
$ row = array(
'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>< /表>;
?>
这工作正常,我不知道问题是什么?我只是不知道 $ a
通过
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>
<td>'.$row['count'].'</td>
</tr>';
I've tried the above, but it doesn't seem to work. It shows the usernames, but they don't have any hyperlinks.
Thanks
<?php
$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
这篇关于表中的超链接 - '< a href ="">'。$ row ['username']。'< / a>'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!