<?php session_start(); include "functions.php"; ConnectToDataBase(DBName()); if ($_POST['utor']) { $_SESSION['schedule'] = $_POST['utor']; $result = makeSchedule($_POST['utor']); if ($result < 0) { header('Location: index.html'); } } // If there is no current logged in user, redirect to the log in page if (!isset($_SESSION['schedule'])) { header('Location: index.html'); } // Choose which semester's timetable to get $schedule = $_SESSION['schedule']; if ($_GET['sem'] == "") { $sem = "fall"; } else { $sem = $_GET['sem']; } // get all POST variables extract($_POST); switch ($action) { case "Add": insertCourse($schedule, $sem, $crs, $lec, $tut, $pra); break; case "Edit": editCourse($schedule, $sem, $crs, $lec, $tut, $pra);
<?php include "functions.php"; ConnectToDatabase(DBName()); function update($sem) { foreach (glob("./{$sem}/*.csv") as $filename) { $dept = substr($filename, 0, -4); if ($sem == "fall") { $dept = substr($dept, 7); } else { if ($sem == "winter") { $dept = substr($dept, 9); } } echo $dept . "\n"; if (($handle = fopen($filename, "r")) !== FALSE) { Query("DROP TABLE IF EXISTS {$dept}"); Query("CREATE TABLE IF NOT EXISTS {$dept} (NAME text, SECTION text, \n\t\t\t\tDAY text, START time, FINISH time, LOCATION text)"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $q = "INSERT INTO {$dept} VALUES ("; foreach ($data as $key => $value) { $q .= "'{$value}',"; } $q = substr($q, 0, -1); $q .= ")"; Query($q); } fclose($handle); } }