所以我试图从用户表中选择用户名表,如果他们在一个团伙中。
使用的Vars:
$member_gang = mysql_fetch_assoc(mysql_query("SELECT level,gangid,rating FROM user_stats WHERE id = '" . $_SESSION['user']['id'] . "'"));
$gang_info = mysql_fetch_assoc(mysql_query("SELECT * FROM gangs WHERE id = '".$member_gang['gangid']."'"));
这是我想要显示它的时候。
$getmembers = mysql_fetch_assoc(mysql_query("SELECT * FROM user_stats WHERE gangid = '" . $gang_info['gangid'] . "'"));
$displaymembers = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id = '" . $getmembers['id'] . "'"));
echo 'One Member of this gang is: <b>'.$displaymembers['username'].' </b>:)';
(我确实有数据库连接等..)它没有回显用户名?!
编辑:我不擅长PHP,我不懂准备好的陈述?答案 0 :(得分:1)
$gang_info['id']
不
$gang_info['gangid']
因为你在上面写了
"SELECT * FROM gangs WHERE id...."
而不是
"SELECT * FROM gangs WHERE gangid..."
你为什么要把'Ids'设置在''?他们是字符串吗?如果没有,将它们更改为整数,这是更好的主键解决方案。