Esempio n. 1
0
}
$pid = $_SESSION['personid'];
echo "<form name='submit1' method='POST' action='subscribeModule.php'>";
$rows = get_sensors($conn);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $submit = $_POST['sensors'];
    $i = 0;
    foreach ($rows as $row) {
        if (!empty($submit) and in_array($row['SENSOR_ID'], $submit)) {
            add_subscription($conn, $row['SENSOR_ID'], $pid);
        } else {
            remove_subscription($conn, $row['SENSOR_ID'], $pid);
        }
        $i++;
    }
    echo "Subscribed to selected sensors. (Total:" . count(get_subscribed_sensors($conn, $pid)) . ")";
}
echo "<table border='1' class='table table-hover'>";
echo "<tr><td>Subscribed</td><td>SENSOR_ID</td><td>LOCATION</td></tr>";
foreach ($rows as $row) {
    if (is_subscribed($conn, $row['SENSOR_ID'], $pid)) {
        echo "<tr><td><input type='checkbox' name='sensors[]' value='" . $row['SENSOR_ID'] . "' checked></td>";
        echo "<td>" . $row['SENSOR_ID'] . "</td>";
        echo "<td>" . $row['LOCATION'] . "</td></tr>";
    } else {
        echo "<tr><td><input type='checkbox' name='sensors[]' value='" . $row['SENSOR_ID'] . "'></td><td>" . $row['SENSOR_ID'] . '</td><td>' . $row['LOCATION'] . '</td></tr>';
    }
}
echo "</table>";
oci_close($conn);
echo "<br>";
Esempio n. 2
0
            <option value="w" <?php 
echo isset($_POST['analysis_range']) && $_POST['analysis_range'] == 'w' ? 'selected="selected"' : '';
?>
>Weekly</option>
            <option value="d" <?php 
echo isset($_POST['analysis_range']) && $_POST['analysis_range'] == 'd' ? 'selected="selected"' : '';
?>
>Daily</option>
        </select> 
    </div>
    <div class='col-xs-3'>
    	<select name='analysis_sid' class='form-control'><br>
        <label for="analysis_sid">Search Range</label> 
            <option disabled selected>--Select Sensor ID--</option>
            <?php 
$sensors = get_subscribed_sensors($conn, $pid);
if (empty($sensors)) {
    echo "<option disabled selected>None Available</option>";
} else {
    foreach ($sensors as $sensor) {
        if (isset($_POST['analysis_sid']) && $_POST['analysis_sid'] == $sensor['SENSOR_ID']) {
            echo "<option value=" . $sensor['SENSOR_ID'] . ' selected="selected">' . $sensor['SENSOR_ID'] . "</option>";
        } else {
            echo "<option value=" . $sensor['SENSOR_ID'] . ">" . $sensor['SENSOR_ID'] . "</option>";
        }
    }
}
?>
        </select> 
    </div>
    <button type="submit" class="btn btn-primary" id='searchBtn' name="searchBtn">Submit</button>