我正在尝试嵌套两个 while 循环和一个 if 语句。
$Query = "SELECT * from lijst";
$Query2 = "SELECT * from users";
$Result = mysql_query( $Query );
$Result2 = mysql_query( $Query2 );
$Return = "<lijst>";
while ( $Lijst = mysql_fetch_object( $Result ))
{
$Return .= "<lijst>";
while ($Users = mysql_fetch_object( $Result2 ))
{
if($Lijst['userid'] == $Users['userid'])
{
$Return .= "<username>".$Users->username."</username>";
}
}
$Return .= "<lijstid>".$Lijst->lijstid."</lijstid>";
$Return .= "</lijst>";
}
$Return .= "</lijst>";
mysql_free_result($Result);
mysql_free_result($Result2);
print ($Return)
但是,我没有得到任何结果。我究竟做错了什么?