'.$menu.'
'; if ($title != "Login") echo '

'.$title.'

'; } // Print html footer with bootstrap js function print_html_footer() { echo '
'; } /* ------------------------- Main Menu Functions ---------------------------- */ // Get main menu items function get_menu_items($title) { $items['home.php'] = "Home"; $items['play_trivia.php'] = "Play Trivia"; $items['view_leaders.php'] = "View Leader Board"; $items['rank_question.php'] = "Rank Questions"; $items['insert_question.php'] = "Insert Question"; if ($_SESSION['admin']) { $items['insert_user.php'] = "Delete User"; $items['delete_question.php'] = "Delete Question"; } $items['logout.php'] = "Logout"; foreach ($items as $key=>$value) { $active = ''; if ($value==$title) $active = "active"; $menu_items .= ' '; } return $menu_items; } // Make main menu with basic Bootstrap classes function make_menu($title) {; $menu = ''; return $menu; } // Make main menu with responsive Bootstrap classes function make_menu_bs($title) { $menu = ' '; return $menu; } /* ------------------------- Prints the homepage ---------------------------- */ // Prints the home page content function print_home() { echo '

Welcome '.$_SESSION['username']. ' you can play trivia or insert questions. Use the main menu above to select additional options or to logout.

'; } /* ------------------------- Login Forms ---------------------------- */ // Print a basic login form function print_login_form($error) { echo '
'.$error.'
'; } // Print a login form with Bootstrap function print_login_bs($error) { if ($error) { $message = '
Incorrect username or password
'; } echo '

Login

'.$message.'
'; } /* ------------------------- Reusable functions ---------------------------- */ // Print a button with specified url and text function print_button($url, $text) { echo ''.$text.''; } /* Print the question table. Must pass an open database connection Thus, you can use this with other scripts (insert question and delete question) verify that they worked */ function print_question_table($mysqli) { // First, print the columns, i.e, field names $result = $mysqli->query("SHOW COLUMNS FROM Questions"); echo ''; echo ''; echo ''; while ($row = $result->fetch_row()) { echo '"; } echo ''; echo ''; $result->close(); // Second, print all the rows $result = $mysqli->query("SELECT * FROM Questions ORDER BY id DESC"); echo ''; while ($row = $result->fetch_row()) { echo ''; foreach ($row as $value) { echo ''; } echo ''; } echo ''; echo '
'.$row[0]."
'.$value.'
'; $result->close(); } /* ------------------------- Insert Questions Forms ---------------------------- */ // Print the insert question form function print_insert_question_form($action, $error, $p) { $c[$p['answer']] = "checked"; $message = ''; if ($error) $message = "All fields must be filled out"; echo '





'.$message.'
'; } // Print the insert question form using Bootstrap and a multicolumn responsive layout function print_insert_question_form_bs($action, $error, $p) { $c[$p['answer']] = "checked"; $message = ''; if ($error) { $message = '
All fields must be filled out
'; } echo '
Answer
'. $message.'
'; } ?>