Has anyone used wordpress?

WBOY
Release: 2023-03-02 12:56:02
Original
908 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
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!