我有一个从WordPress数据库读取数据的插件。我希望管理员能够使用数据的ID从数据库中删除记录。。。我试过了
if ($_GET) {
if ( isset( $_GET[\'in_delete\'] ) ) {
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM bookings" );
foreach ( $result as $print ) {
$id = $print->id;
$del = $wpdb->delete( \'bookings\', $id );
if ( $del ) {
echo "<script>
alert(\'record deleted\');
</script>";
}
}
}
}
我的按钮是
<form action="" name="operations" method="get" >
<input type="button" name="in_delete" value="Delete" style="color:#fff; height:19px; width: 60px; font-size:10px; background-color: red;cursor: pointer;"><br>
</form>