Search
Close this search box.

Create a table in wordpress with functions.php

Amitpal Singh
Amitpal Singh
August 4, 2020

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');

Share this post:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.