-1

我试图将我的申请列在一个列表中,以便他们可以被批准或拒绝。我之前已经完成了许多选择和显示,但由于某种原因,这个不起作用。它显示表格...例如:用户名,你是谁?等等,但它没有显示 $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/>";
        }
4

2 回答 2

2

mysql_fetch_row()返回一个数值数组。

试试mysql_fetch_assoc()吧。这将返回一个关联数组,它看起来就是您要查找的内容。

于 2013-10-05T01:20:03.903 回答
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

于 2013-10-05T01:21:09.253 回答