Location: PHPKode > scripts > WPQuiz > wpquiz/wpquiz_install.php
<?php


global $wpquiz_db_version;
$wpquiz_db_version = "1.0";

global $wpdb;
global $wpquiz_db_version;

add_option("wpquiz_db_version", $wpquiz_db_version);

$table_name1 = $wpdb->prefix . "wpquiz_questions";
  
$sql1 = "CREATE TABLE " . $table_name1 . " (
  id mediumint(9) NOT NULL AUTO_INCREMENT,	  
  question VARCHAR(200) DEFAULT '' NOT NULL,
  answers TEXT NOT NULL,
  correctAnswer mediumint(9) NOT NULL,
  quizid mediumint(9) NOT NULL,
  UNIQUE KEY id (id)
);";
		
$table_name2 = $wpdb->prefix . "wpquiz_quiz";

$sql2 = "CREATE TABLE " . $table_name2 . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,	  
quiztitle VARCHAR(200) DEFAULT '' NOT NULL,	  
UNIQUE KEY id (id)
);";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql1);
dbDelta($sql2);

  
$testq_question = "How many sides in a triangle";
$testq_answerid = 3;

$rows_affected = $wpdb->insert( $table_name2, array( 'quiztitle' => "Do you know your geometry") );
$quizid = $wpdb->insert_id ;
$rows_affected = $wpdb->insert( $table_name1, array( 'question' => "How many sides in a triangle", 'answers' => "2\n3\n4\n5", 'correctAnswer' => "2", 'quizid' => $quizid ) );
$rows_affected = $wpdb->insert( $table_name1, array( 'question' => "How many sides in a rectangle", 'answers' => "2\n3\n4\n5", 'correctAnswer' => "3", 'quizid' => $quizid ) );
$rows_affected = $wpdb->insert( $table_name1, array( 'question' => "How many sides in a pentagon", 'answers' => "2\n3\n4\n5", 'correctAnswer' => "4", 'quizid' => $quizid ) );

?>
Return current item: WPQuiz