0

我的 json 是重复的。
见图片:http: //i.stack.imgur.com/e8Ehn.png

在材料是重复的。我的数据库字段材料是主键,并且roomNum 107,109在数据库中为空,但它的显示。
这是我的代码php:

$sql = "select room.id as roomid,fl_id,roomNum,room.type,rWidth,rHeight,room_type,bu_id,fl_num from room INNEr JOIN room_type ON room.type = room_type.id INNER JOIN floor ON room.fl_id = floor.id
where floor.bu_id = '$buid' and roomNum LIKE '%$roomno%' ORDER BY bu_id asc , roomNum asc";
$q = mysql_query($sql);
$qnum = mysql_num_rows($q);

$ii = 0;
if($qnum > 0){
    $returnar = array();
    while ($row = mysql_fetch_assoc($q)) {      
        $rtype["room"]["id"] = $row["roomid"];
        $rtype["room"]["fl_id"] = $row["fl_id"];
        $rtype["room"]["roomNum"] = $row["roomNum"];
        $rrrr = mysql_query("select * from relation INNER JOIN material ON material.id = relation.mat_id INNER JOIN mat_type ON mat_type.id = material.type where relation.r_id = ".$row["roomid"]." ");
        while ($rowr = mysql_fetch_assoc($rrrr)) {
            $rtype["room"]["material"][] = $rowr["serial_number"];
        }
        array_push($returnar, $rtype);

    }
    echo stripslashes(json_encode($returnar)); 

}

请帮帮我。

4

0 回答 0