如何循环遍历MYSQL表,并使用每行中的值逐行运行计算,直到找到具有正确值的行?即
$records = mysqli_query($mysqli, "select * from TABLE");
while($row = mysqli_fetch_array($records)) {
$valueA = $row['colA'];
// use $valueA as part a complex calculation
if ($valueA is the correct variable in this calculation) {
// do something
}
else { //try next row }
elseif (// if all rows have been checked and no variable was useful) {
// do something else
}
我知道这不是这个代码的正确格式,但我希望它能解释我想要做的事情。感谢
SQL中的用户WHERE语句
示例:
SELECT name FROM customer WHERE id = 10;
name是您要从表中选择的内容(基本上就是您的列(
customer就是表名
id就属于您的搜索条件。