是否可以只使用静态页面在wordpress的当前数据库中创建表(不作为插件创建)?
我写的代码如下:是否可以只使用静态页面在wordpress的当前数据库中创建表(不作为插件创建)?,wordpress,Wordpress,我写的代码如下: <?php /* Template Name:Register Page Template URI: Author:yuva Author URI: Description:This Is Page for Gallery. */ get_header(); ?> <div class="regist"> <h2><?php the_title(
<?php
/*
Template Name:Register Page
Template URI:
Author:yuva
Author URI:
Description:This Is Page for Gallery.
*/
get_header();
?>
<div class="regist">
<h2><?php the_title(); ?></h2>
<?php
global $wpdb;
$my_table=$wpdb->prefix.'your_users';
$sql="CREATE TABLE IF NOT EXISTS $my_table (id int(20) not null auto_increment,name varchar(40) not null,password varchar(20) notnull,PRIMARY KEY(id))";
include_once(ABSPATH.'wp-admin/includes/upgrade.php');
dbDelta($sql);
?>
</div>
<?php
get_footer();
?>
有谁能帮我解决这个问题吗
谢谢大家! 既然此代码没有与用户交互的功能,那么在function.php中编写上述代码而不是在模板页面中如何
是的,如果您愿意,您当然可以创建表。是的,这是可能的,但如果不存在,请不要忘记使用
创建表。
。否则,每次执行页面时,您的查询都会创建新表,并且您以前的数据将丢失。是的,这是可能的:)