//$db->debug=1;
    for ($i = $room_nr_start; $i <= $room_nr_end; $i++) {
        if (!$ward_obj->RoomExists($i)) {
            $beds = 'beds' . $i;
            $info = 'info' . $i;
            $_POST['room_nr'] = $i;
            if (empty(${$beds})) {
                ${$beds} = DEFAULT_NR_OF_BEDS;
            }
            $_POST['nr_of_beds'] = ${$beds};
            if (empty(${$info})) {
                $_POST['info'] = ' ';
            } else {
                $_POST['info'] = ${$info};
            }
            if ($ward_obj->saveWardRoomInfoFromArray($_POST)) {
                $saved_ok = true;
            }
            //echo $ward_obj->getLastQuery().'<p>';
        }
    }
    if ($saved_ok) {
        header("location:nursing-station.php" . URL_REDIRECT_APPEND . "&edit=1&ward_nr={$ward_nr}&retpath=ward_mng");
        exit;
    } else {
        echo $ward_obj->getLastQuery();
    }
} else {
    /* Get the ward's data */
    $ward =& $ward_obj->getWardInfo($ward_nr);
}