<?php require "./shared_methods_and_data.php"; $all_results = get_entire_table($results_table); $user_name = ''; $top_result = 0; while ($row = mysql_fetch_array($all_results)) { if ($row['user_result'] > $top_result) { $user_name = $row['user_name']; $top_result = $row['user_result']; } } update_sql_table($results_table, 'user_name', $user_name, 'user_result', $winner_score); ?> <html><head> <meta http-equiv="refresh" content="1;url=control_panel.html"> </head><body></body></html>
function copy_question_like($term) { //Import variables global $sql_user_name; global $sql_password; global $db_name; global $results_table; global $questions_table; global $init_result; global $question_validity_time; global $points_per_question; global $questions_bank; $result = search_sql_table($questions_bank, 'question', $term); $sql_connection = mysql_connect("localhost", $sql_user_name, $sql_password); if (!$sql_connection) { die("MySQL error :" . mysql_error()); } //DEBUGGING CODE : Attempt to create Database and table and ignore all errors mysql_query("CREATE DATABASE " . $db_name, $sql_connection); //Select the database that we will be working with mysql_select_db($db_name, $sql_connection); //DEBUGGING CODE : Attempt to create the Table and ignore all errors mysql_query("CREATE TABLE " . $questions_bank . "(question_id int NOT NULL AUTO_INCREMENT,PRIMARY KEY(question_id),question varchar(255),choice_1 varchar(255),choice_2 varchar(255),choice_3 varchar(255),correct_choice varchar(255),start_time varchar(255))", $sql_connection); mysql_query("CREATE TABLE " . $questions_table . "(question_id int NOT NULL AUTO_INCREMENT,PRIMARY KEY(question_id),question varchar(255),choice_1 varchar(255),choice_2 varchar(255),choice_3 varchar(255),correct_choice varchar(255),start_time varchar(255))", $sql_connection); //END DEBUG CODE if (!$result) { echo "No questions Available From that Catagory"; return; } $row = mysql_fetch_array($result); if ($row['question'] == '') { echo "No questions Available From that Catagory"; return; } mysql_query("INSERT INTO " . $questions_table . " VALUES (NULL,\"" . $row['question'] . " \",\"" . $row['choice_1'] . "\",\"" . $row['choice_2'] . "\",\"" . $row['choice_3'] . "\",\"" . $row['correct_choice'] . "\",\"" . (time() + 10) . "\")", $sql_connection); //DEBUG CODE echo "Question '" . $row['question'] . "' with the correct answer '" . $row['correct_choice'] . "' inserted"; update_sql_table($questions_bank, 'question', $row['question'], 'question', ''); return; }