【发布时间】:2017-07-17 13:23:55
【问题描述】:
我刚开始学习 PHP,想为数组中的所有值调用 SQL 更新查询。但我不知道在 PHP 中执行它。
<?php
$array = array("12345","23456","34567");
//now here how to call each value of arrayy
foreach ($array as $arr) {
$sql_points1 = "UPDATE user_earning SET points = points + '80' WHERE user_number = '//how to get value of number from array.'";
$result_points1 = $conn->query($sql_points1);
if ($result_points1 === TRUE) {
echo "Current points added ";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>
【问题讨论】:
-
我们需要查看您的数组结构以确定如何从中获取值。如果数据是敏感的,请弥补。
-
好的,我会更新我的问题。
-
您只是在问如何从数组中获取值吗? php.net/manual/en/language.types.array.php
-
不问如何从数组中获取值并放入mysql查询以更新值。
-
$array = '12345'不是数组,但这是$array = array(1,2,3,4,5)
标签: php mysql sql-server