在表格中显示* [英] Displaying * in a table
问题描述
我有2张桌子.一种叫做用户&另一个叫做电视节目.用户表具有:users_id,显示名,用户名和密码,我有一个名为users_id的外键,在电视节目表中,我有tv_id,users_id FK,tvshow,季节.我希望能够显示用户表中显示名称的显示名称,而不是显示分配给他的编号ID.
I have 2 tables. One called users & the other called tv shows. The users table has: users_id, displayname, username and password, I have a foreign key called users_id and in the tv shows table I have tv_id, users_id FK, tvshow, seasons. I want to be able to display the displayname from the users table as to who created it rather than displaying the number id he is assigned.
推荐答案
使用以下SQL查询来获取有关用户的信息:
Use the following SQL query to fetch information about the user:
SELECT users.username,
tv_shows.*
FROM tv_shows
LEFT JOIN users
ON users.users_id = tv_shows.user_id
然后使用以下PHP代码段显示有关用户的信息:
And then display the information about the user using the following PHP snippet:
echo '<td>'.
'<a href="users.php?username='.
$row['username'].
'">'.
$row['username'].
'</a></td>';
这篇关于在表格中显示*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!