【发布时间】:2020-05-30 00:32:20
【问题描述】:
我的 WordPress 表名为 wp_fes_vendors,共有 12 列。
在这 12 列中,我只想更新列名 requests 的数据
我为此列获取的数据来自存储在$_POST['getval'] 中的后端自定义表单
这是我尝试过的代码
if (!empty(isset($_POST['getval'])))
{
global $wpdb;
$table_name=$wpdb->prefix.'fes_vendors';
$data_array = array(
'requests' => $_POST['getval']
);
$data_where = array('requests' => $_POST['getval']);
$wpdb->update($table_name,$data_array,$data_where);
}
HTML
<form id="myForm" name="myform" action="" method="POST" style="padding:20px;">
<label> Select if this Vendor wishes to receive customer requests or not: </label>
<select name="getval" id="brandSel" size="1">
<option selected="selected" disbaled value="">-- Select status --</option>
<option value="1">Enable</option>
<option value="0">Disable</option>
</select>
<?php submit_button('submit'); ?>
</form>
我尝试了几次,但数据没有被保存/更新。 这是db的图片
【问题讨论】: