你好,我有数据数组
function help_upd2($id)
{
$sql = $this->db->query("SELECT * FROM outbound WHERE id_outbound_voice='$id' ")->result();
$data = array();
foreach ($sql as $value) {
$data[] = $value->qty_outbound;
}
echo "<pre>", print_r($data);
// $a = $data * 100000;
// $this->db->query("UPDATE outbound SET total = '$a' WHERE id_outbound_voice = '$id'");
}
$data输出->
Array
(
[0] => 5 // * 100000
[1] => 1 // * 100000
[2] => 1 // * 100000
)
这里我想更新输出值*100000
当您从数据库中提取数据时,它会将它们作为字符串提取,因此您需要对它们强制转换int以进行数学运算。在循环$data[] = (int) $value->qty_outbound * 100000;
中执行此操作