-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-region.php
51 lines (48 loc) · 1006 Bytes
/
add-region.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
include '../core/inc.php';
include 'db/cognizdb.php';
include 'db/cognizqueries.php';
if($_POST) {
$region = $_POST['region'] ?? '';
$sel = $_POST['sel'] ?? '';
if (isset($sel)){
foreach ($sel as $s){
$up = $cdb->prepare("UPDATE IGNORE groups SET region=? WHERE id=?");
$up->execute(array($region,$s));
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
label {display: block;}
</style>
</head>
<body>
<form method="POST">
<select name="region">
<?php
include 'regions.php';
foreach($regions as $key => $value){
echo '<option value="'.$key.'">'.$value.'</option>'."\n";
}
?>
</select>
<?php
function get_nr_groups($db){
$query = $db->query("SELECT * FROM groups WHERE ISNULL(region) ORDER BY id ASC");
$q = $query->fetchAll(PDO::FETCH_ASSOC);
return $q;
}
$data = get_nr_groups($cdb);
foreach ($data as $d){
echo '<label><input type="checkbox" name="sel[]" value='.$d['id'].' /> '.$d['name'].'</label>'."\n";
}
?>
<input type="submit" value="submit!" />
</form>
</body>
<html>