<?php // in this we will include the files of functions and check if the user is instructor // we will assume the user is logged in //include('includes/functions.php'); //dbconnect("localhost", "quizuser", "quiz", "quiz"); include "layout/adminheader.php"; $question_id = $_GET['quid']; $row = get_question($question_id); $choices = get_choices($question_id); $array_of_choices = array(); $choices_id = array(); while ($rows = mysqli_fetch_assoc($choices)) { array_push($array_of_choices, $rows['content']); array_push($choices_id, $rows['id']); } //print_r($array_of_choices[]); // in add press the data will be saved and send to database if (isset($_POST['update'])) { // save it to database with the current quiz id // unset($_SESSION['question_error']); $content = $_POST['content']; $correct = $_POST['correct_answer']; $choice_1 = $_POST['choice_1']; $choice_2 = $_POST['choice_2']; $choice_3 = $_POST['choice_3']; $choice_4 = $_POST['choice_4']; //$choices=array(); //print_r($_POST); if ($correct == 1) { $correct = $choice_1;
<?php session_start(); $_GET['pagename'] = 'list'; include "setting.php"; if (!isset($_GET['id']) || !isset($_SESSION['id']) || !isset($_SESSION['ipaddress'])) { gotoindex(); } check_login(); if (!is_numeric($_GET['id'])) { exit(0); } include "header.php"; $id = $_GET['id']; $q_result = get_question($id); $c_result = get_choices($id); if ($q_result == false || $c_result == false) { print "診断が存在しません。"; exit(0); } else { $question = pg_fetch_assoc($q_result, 0); $dt = date("Y-m-d H:i:s", strtotime($question['date'])); print "診断:{$question['content']}<br>"; print "作成日時:{$dt}<br><br>"; print "質問:{$question['question']}<br><br>"; $num = pg_num_rows($c_result); for ($i = 0; $i < $num; $i++) { $choice = pg_fetch_assoc($c_result, $i); print "<button onclick=\"location.href='answer.php?id={$id}&ans={$choice['id']}'\">" . $choice['choice'] . "</button><br><br>"; } }