Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="description" content="quiz managment" />
- <meta name="keywords" content="PHP, MySql, assignment3" />
- <title>Mangement</title>
- </head>
- <body>
- <h1>Quiz Results database search</h1>
- <?php
- require ("settings.php"); //connection info
- $conn = @mysqli_connect($host,
- $user,
- $pwd,
- $sql_db
- );
- if (!$conn) {
- echo "<p>Database connection failure</p>";
- }
- //checks if connection is succesful and displays a error message if connection isnt successful
- else {
- $sql_table = "attempts";
- if (isset ($_POST["all"])) {
- $query = "SELECT * FROM attempts";
- $result = mysqli_query($conn, $query);
- var_dump($result);
- }
- else { echo "<p>all</p>";}
- if (isset ($_POST["student"])) {
- $student = $_POST["student"];
- $query = "SELECT * FROM attempts WHERE student_id like '$student' or first_name like '$student'";
- $result = mysqli_query($conn, $query);
- var_dump($result);
- }
- else {echo "<p>student</p>";}
- if (isset ($_POST["hund"])) {
- $query = "SELECT * FROM attempts WHERE score=5 and attempts=1";
- $result = mysqli_query($conn, $query);
- var_dump($result);
- }
- else { echo "<p>hundo</p>";}
- if (isset ($_POST["fif"])) {
- $query = "SELECT * FROM attempts WHERE score<=2 and attempts=3";
- $result = mysqli_query($conn, $query);
- var_dump($result);
- }
- else {echo "<p>fifty</p>";}
- if (isset ($_POST["delete"])) {
- $student = $_POST["delete"];
- $query = "DELETE FROM attempts WHERE student_id like '$student'";
- }
- else {echo "<p>delete</p>";}
- if (isset ($_POST["score"])) {
- $student = $_POST["score"];
- $change = $_POST["changeattempt"];
- $value = $_POST["value"];
- $query = "UPDATE attempts SET score = '$value' WHERE attempts = '$change' and student_id = '$student'";
- }
- else {echo "<p>scorechange</p>";}
- if (!$result) {
- echo "<p>Somethinng is wrong with ", $query, "</p>";
- }
- else {
- echo "<table border=\"1\">\n";
- echo "<tr>\n "
- ."<th scope=\"col\">First Name</th>\n "
- ."<th scope=\"col\">Last Name</th>\n "
- ."<th scope=\"col\">Student ID</th>\n "
- ."<th scope=\"col\">Attempt</th>\n "
- ."<th scope=\"col\">Score</th>\n "
- ."</tr>\n ";
- //retrive current record point by the record pointer
- while ($row = mysqli_fetch_assoc($result)) {
- echo "<tr>\n ";
- echo "<td>", $row["first_name"], "</td>\n ";
- echo "<td>", $row["last_name"], "</td>\n ";
- echo "<td>", $row["student_id"], "</td>\n ";
- echo "<td>", $row["attempts"], "</td>\n ";
- echo "<td>", $row["score"], "</td>\n ";
- echo "</tr>\n ";
- }
- }
- echo "</table>\n ";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement