我目前正在使用個人使用的插件,但我無法獲得插件來創建表格,我嘗試激活插件但它不創建表格,這裏是我的代碼:Wordpress Plugin創建數據庫表
團隊monobattle-registraion.php:
<?php
/*
Plugin Name: Team Monobattle Registration
Plugin URI: http://www.web-geeks.com/
Description: Plugin for registering teams for monobattles.
Author: Web-geeks
Version: 1.0
Author URI: http://www.web-geeks.com/
*/
function tmbr_admin() {
include('team-monobattle-admin.php');
}
function tmbr_admin_actions() {
add_options_page('Team Monobattle Registration', 'Team Monobattle Registration', 'manage_options', 'tmbr', 'tmbr_admin');
}
add_action('admin_menu', 'tmbr_admin_actions');
include('team-monobattle-database.php');
register_activation_hook(__FILE__, 'tmbr_install');
?>
團隊monobattle-database.php中:
<?php
global $tmbr_db_table_version;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$tmbr_db_table_version = "1.0";
global $wpdb;
function tmbr_install()
{
global $tmbr_db_table_version;
$installed_ver = get_option("tmbr_db_table_version");
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != 'wp_teammonobattleteams' || $installed_ver != $tmbr_db_table_version) {
$sql = "CREATE TABLE wp_teammonobattleteams (
teamid mediumint(9) NOT NULL AUTO_INCREMENT,
teamname tinytext NOT NULL,
pname1 tinytext NOT NULL,
pid1 smallint NOT NULL,
pname2 tinytext NOT NULL,
pid2 smallint NOT NULL,
pname3 tinytext NOT NULL,
pid3 smallint NOT NULL,
pname4 tinytext NOT NULL,
pid4 smallint NOT NULL,
UNIQUE KEY id (id)
);";
dbDelta($sql);
echo('installed');
}
}
?>
團隊monobattle-admin.php的:
<div class="wrap">
<?php echo "<h2>" . __('Team Monobattle Admin', 'tmbr_admin') . "</h2>"; ?>
</div>
幫助讚賞。
有人可以幫我....請!!!! – techy
任何錯誤消息?你可以讀表嗎? – mrtsherman