PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table `sortlist` (id int, count1 int, count2 int, count3 int);
Copy Clear
Copy Format Clear
<?php $conn = &$mysqli; $data = [ ['id'=>'11-2', 'count'=>4], ['id'=>'12-3', 'count'=>2] ]; $stmt = $conn->prepare( "UPDATE `sortlist` SET `count1` ='count1' + ? , `count2` ='count2' + ? , `count3` ='count3' + ? WHERE `id`= ? ;" ); $stmt->bind_param('iiis', $count1, $count2, $count3, $row); foreach ($data as $value) { list($row, $col) = explode("-", $value['id']); $count1 = 0; $count2 = 0; $count3 = 0; $column = "count" . intval($col); $$column = $value["count"]; echo "$count1, $count2, $count3, $row"; $stmt->execute(); }
Show:  
Copy Clear