0

我正在尝试进行批量操作。我有复选框,

<input type="checkbox" name="check_id[]" value="1">
<input type="checkbox" name="check_id[]" value="2">
<input type="checkbox" name="check_id[]" value="3">

我想为每个选定的复选框从 mysql 表中选择值,然后使用我的函数根据获取的值删除数据。我试过了,

for( $i = 0; $i < count( $_POST['check_id'] ); $i++ ) {
  $manufacturers_id = prepare_input($_POST['check_id'][$i]);
  $manufacturer_query = mysql_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$manufacturers_id . "'");
  $manufacturer = mysql_fetch_array($manufacturer_query);

  delete_image(DIR_IMAGES . $manufacturer['manufacturers_image']);
}

问题是,$_POST['check_id']即使我确定我的manufacturers_image位置是manufacturers_id1,2 或 3,也没有基于获取的 mysql 值。

有没有正确的方法来做到这一点?

4

2 回答 2

1

更改此行

$manufacturer = mysql_fetch_array($manufacturer_query);

$manufacturer = mysql_fetch_assoc($manufacturer_query);
于 2012-08-18T12:58:00.960 回答
0

它正在返回一个数组...您使用while()或获取第一张图像

delete_image(DIR_IMAGES . $manufacturer[0]['manufacturers_image']);
于 2012-08-18T11:59:48.580 回答