我的代码有问题。mysql_fetch_array 输出重复相同的值。这是我的代码:
$sql= "SELECT client.resID AS resID, client.resName AS resName, menu.id AS mid, menu.name AS mname, facilities.name AS fname, facilities.id AS fid FROM client INNER JOIN menu ON client.resID = menu.resID INNER JOIN facilities ON client.resID = facilities.resID WHERE client.resID =".$_GET["resID"];
$rs = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
while ($f = mysql_fetch_array($rs)) { // loop as long as there are more results
$names[] = $f['mname']; // push to the array
print_r($names)
}
假设一家餐馆有米饭和土豆。print_r($names) 正在返回:
Array ( [0] => rice [1] => potato [2] => rice [3] => potato [4] => rice [5] => potato [6] => rice [7] => potato [8] => rice [9] => potato )
我该如何解决这个问题?非常感谢您的帮助:D