【发布时间】:2016-10-25 06:13:11
【问题描述】:
您好,我有这个 wordpress 项目,我的脚本运行良好并将其保存到数据库中。我的问题是当我插入值 zipcode 2034 并刷新 wp-admin 页面时,我认为数据正在保存,现在我想输入另一个 zipcode 6000 并且第一个输入值被新的值替换。我怎么能从中插入另一个值?不替换保存的数据。下面是我的代码
add_action('admin_menu', 'zipcode_menu');
function zipcode_menu(){
add_menu_page( 'Zipcode Page', 'Zipcode', 'manage_options', 'zipcode', 'zipcode' );
}
add_action( 'admin_init', 'update_extra_post_info' );
function update_extra_post_info() {
register_setting( 'extra-post-info-settings', 'zipcode' );
}
function zipcode() {
// Now display the settings editing screen
echo '<div class="wrap">';
// header
echo "<h2>" . __( 'Zipcode', 'zip' ) . "</h2>";
// settings form
$extra_info = get_option('zipcode');
echo "<pre>";
print_r($extra_info);
echo "</pre>";
?>
<form method="post" action="options.php">
<?php settings_fields( 'extra-post-info-settings' ); ?>
<?php do_settings_sections( 'extra-post-info-settings' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Zipcode:</th>
<td><input type="text" name="zipcode" value="<?php echo get_option( 'zipcode' ); ?>"/></td>
</tr>
</table>
<?php submit_button(); ?>
</div>
<br>
<br>
<table width="600px">
<tr>
<th>
Zipcode
</th>
<th>
Options
</th>
</tr>
<tr>
<th>
</th>
<th>
</th>
</tr>
</table>
<?php
}
我想从数据库中检索所有保存的数据到table 有人可以帮我解决这个问题吗?非常感谢任何帮助。
TIA
【问题讨论】: