Home > Backend Development > PHP Tutorial > Has anyone used wordpress?

Has anyone used wordpress?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-03-02 12:56:02
Original
1025 people have browsed it

Has anyone used wordpress before? How can WordPress create a data table? If it can be created, is there any way to operate the created data table? I used the following code. It is said online that it can be used in a plug-in. But it didn’t work for me. I wrote the code wrong or put it in the wrong place
function wp_user_avatars_create_table() {

<code>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);
}</code>
Copy after login
Copy after login

}

register_activation_hook( __FILE__,'wp_user_avatars_create_table');

Reply content:

Has anyone used wordpress before? How can WordPress create a data table? If it can be created, is there any way to operate the created data table? I used the following code. It is said online that it can be used in a plug-in. But it didn’t work for me. I wrote the code wrong or put it in the wrong place
function wp_user_avatars_create_table() {

<code>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);
}</code>
Copy after login
Copy after login

}

register_activation_hook( __FILE__,'wp_user_avatars_create_table');

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template