$value) { // If any value is blank, we have an error, so break out of the loop if ($value == "") { $error = true; break; } $v .= "'".$value."',"; $k .= $key.","; } // Only run the query if there is no error if (!$error) { // We have to trim the right-most comma from the lists $v = rtrim($v,","); $k = rtrim($k,","); // Connect to datbase and execute query $mysqli = db_connect(); $sql = "INSERT INTO Questions ($k) VALUES ($v)"; $mysqli->query($sql); // Print a button to insert another question print_button("insert_question.php", "Insert Another Question"); /* Print all the questions as a Bootstrap formatted table This is really for debugging and for administrators This shows how you can easily add output by calling reusable functions */ print_question_table($mysqli); $mysqli->close(); } } if (empty($_POST) || $error) { print_insert_question_form_bs("insert_question.php", $error, $_POST, $c); } print_html_footer(); ?>