Suzanna Vellacott-Ford, Richard Burks */ // include general functions include "functions.php"; // connect to database mysql_connect("localhost", "root", "thebigredmachine") or die(mysql_error()); mysql_select_db("chimi") or die(mysql_error()); // get the session ID $sessionID = getSessionCookie(); // get starting and ending index for slots in the selected room $startingIndex = $_GET["starting_index"] + 0; $offset = $_GET["offset"] - 1; $endingIndex = $startingIndex + $offset; // get courses and instructors $courses = jsonString2Obj($_GET["courses"]); $instructors = jsonString2Obj($_GET["instructors"]); // fetch new sections from database $section_result = mysql_query("SELECT courseID, instructorID, slotID, sectionID FROM Section WHERE sessionID='" . $sessionID . "' AND slotID BETWEEN {$startingIndex} AND {$endingIndex} ORDER BY slotID"); $sections = mysql_fetch_all($section_result); for ($i = 0; $i < count($sections); $i++) { // find matching course and instructor for new section $course = binary_search($courses, 0, $sections[$i][0]); $instructor = binary_search($instructors, 0, $sections[$i][1]); // append course and instructor to new section $sections[$i]['course'] = $course; $sections[$i]['instructor'] = $instructor; } // disconnect from database mysql_close(); // return new sections to view echo json_encode($sections);
// CARINA Database tbl_solar_image_data $User_ID = $_SESSION['user_id']; // OLD hard coded for development & testing //$Image_Location = "images/testing/20111215_002729_512_0335.jpg"; // Establish connection to database $con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die(mysql_error()); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (isset($_POST['IMAGE_FILE_NAME'])) { $ImageFileName = $_POST['IMAGE_FILE_NAME']; $annots_x_NORM = jsonString2Obj($_POST['ANNOTS_X_NORM']); $annots_y_NORM = jsonString2Obj($_POST['ANNOTS_Y_NORM']); $annots_x_PIXEL = jsonString2Obj($_POST['ANNOTS_X_PIXEL']); $annots_y_PIXEL = jsonString2Obj($_POST['ANNOTS_Y_PIXEL']); $PixelsX = $_POST['PIXELS_X']; $PixelsY = $_POST['PIXELS_Y']; $sql = "select 2+2 from dual;"; $sql .= "INSERT INTO tbl_collaboration(collaboration_id,user_id, cha_ImageLocation,private_cha_PointID, private_cha_XCoordinate_PIXEL, private_cha_YCoordinate_PIXEL, private_cha_XCoordinate_NORM, private_cha_YCoordinate_NORM, time_in ) VALUES "; $PointID = 1; // $PointID1 = 1; echo $PointID; foreach ($annots_x_NORM as $index => $x) { $sql .= "('" . $PointID . "','{$User_ID}','{$ImageFileName}','" . $PointID . "','" . $annots_x_PIXEL[$index] . "','" . $annots_y_PIXEL[$index] . "','" . $x . "','" . $annots_y_NORM[$index] . "'," . " NOW()),"; $PointID += 1; } $sql_trim = substr($sql, 0, -1); $result = mysqli_multi_query($con, $sql_trim); echo $result; if (!$result) {