我试图将我的应用程序列入其中,以便批准或拒绝。我之前已经选择了很多并且显示但是由于某种原因这个没有用。它显示表格......例如:用户名,你是谁?但它没有显示$ applicationRow ['Username']等。我已经通过mysql编辑器运行查询,它工作正常,所以我知道它不是那样的。它进入了while循环,因为它显示了表...但是为什么它不显示结果???
$applicationQuery = "SELECT tblMembers.Username, tblMembers.Bio, tblApplications.WhyJoin, tblApplications.Games, tblApplications.FoundBy, tblApplications.Joke
FROM tblApplications
INNER JOIN tblMembers ON tblMembers.ID = tblApplications.MemberID
WHERE Approved=0";
echo $applicationQuery;
$applicationResults = mysql_query($applicationQuery) or die(mysql_error());
while($applicationRow = mysql_fetch_row($applicationResults))
{
echo "<table>";
echo "</tr><td>Username:</td><td></td>".$applicationRow['Username']."</tr>";
echo "</tr><td>Who are you?</td><td></td>".$applicationRow['Bio']."</tr>";
echo "</tr><td>What games do you play?</td><td></td>".$applicationRow['Games']."</tr>";
echo "</tr><td>How did you find us?</td><td></td>".$applicationRow['FoundBy']."</tr>";
echo "</tr><td>Why do you want to join?</td><td></td>".$applicationRow['WhyJoin']."</tr>";
echo "</tr><td>Tell us a joke:</td><td></td>".$applicationRow['Joke']."</tr>";
echo "</table><hr/>";
}
答案 0 :(得分:2)
mysql_fetch_row()
返回一个数值数组。
请尝试使用mysql_fetch_assoc()
。这将返回一个关联数组,它出现在你正在寻找的位置。
答案 1 :(得分:0)
更改此
$applicationQuery = "SELECT tblMembers.Username, tblMembers.Bio, tblApplications.WhyJoin, tblApplications.Games, tblApplications.FoundBy, tblApplications.Joke
FROM tblApplications
INNER JOIN tblMembers ON tblMembers.ID = tblApplications.MemberID
WHERE Approved=0";
到
$applicationQuery = "SELECT tblMembers.Username as Username, tblMembers.Bio as Bio, tblApplications.WhyJoin as WhyJoin, tblApplications.Games as Games, tblApplications.FoundBy as FoundBy, tblApplications.Joke ad Joke
FROM tblApplications
INNER JOIN tblMembers ON tblMembers.ID = tblApplications.MemberID
WHERE Approved=0";
因为当您在while循环中获取时,列别名不匹配
并使用mysql_fetch_Array
代替mysql_fetch_row