我有这段代码,可以从数据库获取数据并插入到数组中,也可以将其插入同一数据库中的另一个表中,但我想要的是数据中有一个价格,如果有可用的数据可以是一个或两个,并且将其加在一起时的价格大于特定值,然后执行某些操作
<?php
session_start();
require "../db/dbconn.php";
$sql = "SELECT cartPrice FROM cart";
$result = mysqli_query($conn, $sql);
$datas = array();
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$datas[] = $row;
}
}
foreach($datas as $data) {
$price = $data['cartPrice'];
#so how do i do it if $price is greater than maybe 1000 then do this especially when it loops more than one
$stmt = $conn->prepare("INSERT INTO order (price) VALUES (?)");
$stmt->bind_param("s", $price);
$stmt->execute();
}
有谁知道我该怎么做,如果你不明白,我仍然可以向你解释
慕的地10843