Have you ever used wordpress? This is how wordpress can create a data table. if you can create a data table, is there any way to operate the created data table. I used the following code, which can be used in plug-ins on the Internet. But I didn't use it... have you ever used wordpress? This is how wordpress can create a data table. if you can create a data table, is there any way to operate the created data table. I used the following code, which can be used in plug-ins on the Internet. However, I have used it and it is useless. Is it because my code is wrong or the location is wrong?
Function wp_user_avatars_create_table (){
global $wpdb;$table_name = $wpdb->prefix . "test";if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS " . $tablename . " ( `test_id` int(8) unsigned NOT NULL, `test_name` varchar(200) CHARACTER SET utf8 NOT NULL, `test_password` varchar(200) CHARACTER SET utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; dbDelta($sql);}
}
Register_activation_hook (_ FILE __, 'WP _ user_avatars_create_table ');
Reply content:
Have you ever used wordpress? This is how wordpress can create a data table. if you can create a data table, is there any way to operate the created data table. I used the following code, which can be used in plug-ins on the Internet. However, I have used it and it is useless. Is it because my code is wrong or the location is wrong?
Function wp_user_avatars_create_table (){
global $wpdb;$table_name = $wpdb->prefix . "test";if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS " . $tablename . " ( `test_id` int(8) unsigned NOT NULL, `test_name` varchar(200) CHARACTER SET utf8 NOT NULL, `test_password` varchar(200) CHARACTER SET utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; dbDelta($sql);}
}
Register_activation_hook (_ FILE __, 'WP _ user_avatars_create_table ');