In this lesson we are creating a table in wordpress database using PhpMyAdmin tool.  We export table structure information into SQL format for use in our plugin.

In the following video we will create the same table using wordpress plugin.  Code of the plugin is given below

<?php
/*
Plugin Name: Database Demo
Plugin URI: http://agilesolutionspk.com/training
Description: It shows how shortcodes are created and used
Version: 1.0
Author URI:
Author: Kamran Syed
*/

register_activation_hook( __FILE__, 'install' );

function install(){
global $wpdb;

$sql = "
CREATE TABLE `TRG5_student` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 30 ) NOT NULL ,
`age` INT NOT NULL ,
`course` VARCHAR( 30 ) NOT NULL
)
";

$wpdb->query($sql);

}

Please do not hesitate to ask any questions. Use comments box below for questions.