$sqlLine = "CALL getPollAnswers(" . $temp . ");";
    $question = mysqli_query($connection, $sqlLine) or die("Query fail: " . mysqli_error());
    $incr = 0;
    $arrReturn = array();
    // print out Question answers.
    while ($row = mysqli_fetch_array($question)) {
        $arrReturn[$incr][0] = $row[0];
        $arrReturn[$incr][1] = $row[1];
        $arrReturn[$incr][2] = $row[2];
        $incr++;
    }
    return $arrReturn;
}
//Call Answers and store them into answerArray to print on radio buttons
$conn = new mysqli($servername, $username, $password, $dbname);
$answerArray = callAnswers($pollID, $conn) or die("Query fail: " . mysqli_error());
$conn->close();
//winning
$winning = true;
//Get the total amount of votes for all answers
$totalVotes = 0;
for ($i = 0; $i < count($answerArray); $i++) {
    $totalVotes += $answerArray[$i][2];
}
?>

	<head>
		<title>Results | Polling App</title>
		<link rel="icon" type="image/png" href="imgs/favicon.png">
		<meta charset = "utf-8">
		<meta name = "viewport" content = "width = device-width, initial-scale = 1">
Exemple #2
0
    $arrReturn = array();
    // print out Question answers.
    while ($row = mysqli_fetch_array($question)) {
        $arrReturn[$incr] = $row[0];
        $incr++;
    }
    return $arrReturn;
}
echo "========================TEST==============================<br>";
//Call question and print it out.
$conn = new mysqli($servername, $username, $password, $dbname);
$quest = callQuestion($randID[0], $conn);
$conn->close();
//Call Answers and print them out
$conn = new mysqli($servername, $username, $password, $dbname);
$answerArray = callAnswers($randID[0], $conn);
$conn->close();
for ($i = 0; $i < count($answerArray); $i++) {
    echo $answerArray[$i] . "<br>";
}
//Open connection for debugging purposes.
$conn = new mysqli($servername, $username, $password, $dbname);
echo "========================TEST==============================<br><br>";
//End connection with database
$conn->close();
echo "<br><br>";
?>

<!-- Test out the poll creation again -->

	<form action="pollVote.php" method="post">
    $sqlLine = "CALL getPollAnswers(" . $temp . ");";
    $question = mysqli_query($connection, $sqlLine) or die("Query fail: " . mysqli_error());
    $incr = 0;
    $arrReturn = array();
    // print out Question answers.
    while ($row = mysqli_fetch_array($question)) {
        $arrReturn[$incr][0] = $row[0];
        $arrReturn[$incr][1] = $row[1];
        $arrReturn[$incr][2] = $row[2];
        $incr++;
    }
    return $arrReturn;
}
//Call Answers and store them into answerArray to print on radio buttons
$conn = new mysqli($servername, $username, $password, $dbname);
$answerArray = callAnswers($randID[0], $conn) or die("Query fail: " . mysqli_error());
//Store answers in session variable
$_SESSION['arrReturn'] = $answerArray;
$_SESSION['pollID'] = $randID[0];
$conn->close();
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->close();
//=============================END PHP CODE=================================//
?>

	<head>
		<title>Vote | Polling App</title>
		<link rel="icon" type="image/png" href="imgs/favicon.png">
		<meta charset = "utf-8">
		<meta name = "viewport" content = "width = device-width, initial-scale = 1">