Dark

Light

Dark

Light

Scroll to top

Create a table in wordpress with functions.php

Create a table in wordpress with functions.php

function create_quote_table(){
	
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$quotetable = $wpdb->prefix . "quote";									
	
$createquotetable = "CREATE TABLE $quotetable (
  ID mediumint(9) NOT NULL AUTO_INCREMENT,
  useremail text NOT NULL,
  quote_no text NOT NULL,
  product_ids text NOT NULL,
  date_added text NOT NULL,
  UNIQUE KEY ID (ID)
) $charset_collate;";	

require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $createquotetable );
		
}
add_action('admin_init','create_quote_table');
Author avatar
Amitpal Singh
https://amitpalsingh.com

Post a comment

Your email address will not be published. Required fields are marked *