为什么我的json是重复的?

时间:2013-10-01 19:05:52

标签: php json

我的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)); 

}

请帮帮我。

0 个答案:

没有答案