Пример #1
0
	function get_room_depth($room_id){

		if ($room_id == 1){return 1;}

		list($parent_room_id) = db_list(db_fetch("SELECT id FROM choose_rooms WHERE room_1=$room_id OR room_2=$room_id"));

		if ($parent_room_id){
			return 1 + get_room_depth($parent_room_id);
		}

		return 1;
	}
Пример #2
0
function get_room_depth($room_id)
{
    if ($room_id == 1) {
        return 1;
    }
    //list($parent_room_id) = mysql_num_rows(mysql_query("SELECT id FROM choose_rooms WHERE room_1=".$room_id." OR room_2=".$room_id));
    $parent_room_id = db_single(mysql_query("SELECT id FROM choose_rooms WHERE room_1=" . $room_id . " OR room_2=" . $room_id));
    //echo "<!-- Parent ID: ".$parent_room_id['id']." --/>";
    if ($parent_room_id['id']) {
        return 1 + get_room_depth($parent_room_id['id']);
    }
    return 1;
}