"; print_r($_REQUEST['position']); echo ""; exit; // First start to find the id of the survey we are moving Down. $sql = "SELECT question_id FROM section_questions WHERE sort_order='" . ($_REQUEST['position'] - 1) . "'"; $res = db_query($sql); $row = mysql_fetch_assoc($res); // This is the id of the record that is moving Down one position. $id_moving_down = $row['question_id']; // Move it up one. $sql = "UPDATE section_questions SET sort_order='" . ($_REQUEST['position'] - 1) . "' WHERE question_id='" . $_REQUEST['q_id'] . "'"; $res = db_query($sql); // Now move the one that was on top, down one. $sql = "UPDATE section_questions SET sort_order='" . $_REQUEST['position'] . "' WHERE question_id='" . $id_moving_down . "'"; $res = db_query($sql); // Refresh the page. header("Location: list.php"); exit; } // The user has chosen to move a section down one in the sort order. // Only sections < max(sort_order) are allowed to do this. This is // Checked when the page is loaded. if(isset($_REQUEST['Move_Q_Down'])) { $sql = "SELECT question_id FROM section_questions WHERE sort_order='" . ($_REQUEST['position'] + 1) . "'"; $res = db_query($sql); $row = mysql_fetch_assoc($res); // This is the id of the record that is moving Up one position. $id_moving_down = $row['question_id']; // Move it up one. $sql = "UPDATE section_questions SET sort_order='" . ($_REQUEST['position'] + 1) . "' WHERE question_id='" . $_REQUEST['q_id'] . "'"; $res = db_query($sql); // Now move the one that was on top, down one. $sql = "UPDATE section_questions SET sort_order='" . $_REQUEST['position'] . "' WHERE question_id='" . $id_moving_down . "'"; $res = db_query($sql); header("Location: list.php"); exit; } /* End Submission Checks */ /* * Begin onLoad * This section loops through all the surveys and checks to see if sections * exist for that survey. If there are sections, then loop through all of them * checking to see if questions exist for each itteration. If there are questions * print them out. * */ // --Survey // // $sql = "SELECT survey_id, survey_title, sort_order FROM surveys ORDER BY sort_order ASC"; $sur_res = db_query($sql); while($sur_row = mysql_fetch_assoc($sur_res)) { $html .= '