query("SELECT UID, name FROM Section"); $sectionlist = array(); while ($row = $query->fetchArray()) { $sectionlist[$row['UID']] = $row['name']; } echo json_encode($sectionlist); } else if (isset($_GET['getids'])) { $sectionnames = json_decode($_GET['getids']); $sectionids = array(); foreach ($sectionnames as $sectionname) array_push($sectionids, $conn->query("SELECT UID FROM Section WHERE name='$sectionname'")->fetchArray()['UID']); echo json_encode($sectionids); } else { $sections = json_decode($_GET['sections']); $app = new App(true); foreach ($sections as $section) { $app->addSection($section); } } ?>