时间:2021-07-01 10:21:17 帮助过:17人阅读
$arr = array ( 0 => array ( 'id' => 42 ) ,1 => array ( 'id' => 49 ), 2 => array ( 'id' => 50 ), 3 => array ( 'id' => 51 ), 4 => array ( 'id' => 52 ) );
foreach ($arr as $key => $value) {
$sql = "update tableName set count = count + ".($key+1)." where id = ".$value['id'];
mysql_query($sql);
}
$ar = array ( 0 => array ( 'id' => 42 ) ,1 => array ( 'id' => 49 ), 2 => array ( 'id' => 50 ), 3 => array ( 'id' => 51 ), 4 => array ( 'id' => 52 ) );
$s = join(',', array_map('current', $ar));
$sql = "update tbl_name set count=count+find_inset(id,'$s')";
mysql_query($sql);