-
Notifications
You must be signed in to change notification settings - Fork 3
/
saveProgram.php
53 lines (42 loc) · 1.42 KB
/
saveProgram.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
52
53
<?php
include("db.php");
session_start();
if (isset($_SESSION['logget_ind'])) {
openDB();
$eventid = $_POST['eventid'];
// Valid id?
if ($eventid == "" || $eventid < 0) {
echo "invalid eventid";
exit;
}
// Delete the old entries in the ProgramPunkt table
$query = "DELETE FROM ProgramPunkt WHERE ProgramID=" . $eventid;
$result = doSQLQuery($query);
// Insert the new entries
$songcount = $_POST['songcount'];
for ($count = 0; $count < $songcount; $count++) {
$index = 'Song'.$count;
$headIndex = 'Heading'.$count;
$songid = $_POST[$index];
$heading = db_fix_str($_POST[$headIndex]);
//echo "songid:".$index.":".$songid;
$query = "INSERT INTO ProgramPunkt (ProgramID,SangID,Overskrift,Raekkefoelge) VALUES (".$eventid.",".$songid.",'".$heading."',".$count.");";
$result = doSQLQuery($query);
}
// Delete the old entries in the ProgramBruger table
$query = "DELETE FROM ProgramBruger WHERE ProgramID=" . $eventid;
$result = doSQLQuery($query);
// Insert the new entries
$personcount = $_POST['personcount'];
for ($count = 0; $count < $personcount; $count++) {
$brugerid = $_POST['Person'.$count];
$roleid = $_POST['Rolle'.$count];
$query = "INSERT INTO ProgramBruger (ProgramID,BrugerID,RolleID) VALUES (".$eventid.",".$brugerid.",".$roleid.");";
$result = doSQLQuery($query);
}
echo 'done';
closeDB();
} else {
echo 'Ikke logget ind';
}
?>