我使用下面的代码来选择多选值更改。我有两个按钮(是和否)。在此代码中,“是”功能正常,但当我选择多行并单击“否”按钮时,它不起作用。
if (isset($_POST['row_id_to_change_value']))
{
$files_array = explode(",", $_POST['row_id_to_change_value'][0]);
$count = count($files_array);
for ($i = 0; $i <= $count; $i++)
{
if ($files_array[$i] > 0)
{
$show = htmlentities($_POST['file_show']);
update_post_meta($files_array[$i], 'file_show_to_customer', $show);
$show == 'yes' ? $showing = 'show' : $showing = 'hide';
$updated = get_the_title($files_array[$i]) . ' has been updated to <strong>' . show . '</strong>.';
wp_redirect(get_permalink() . '?show=1');
}
}
}
Html Part
<div id="change-visibility-dialog-multiple" style="display:none;">
<form method="post" action="">
<h4>Change the customer's visibility:</h4>
<input type="hidden" name="row_id_to_change_value[]" value="" />
<button class="button-dark" name="file_show" value="no">No<i class="btl bt-ban"></i></button>
<button class="button-submit" name="file_show" value="yes">Yes</button>
</form>
</div>
有什么建议吗?