我是 PHP 初学者,我需要你的帮助,如果查询的所有行都正确:打印一条消息,如果部分或全部不符合条件,则打印另一条消息。
我需要 Qry 和 PHP sintaxis 方面的帮助,我想我需要使用 te COUNT,但我现在不知 Prop 体怎么做。
谢谢。
我的表名称:oder_product
+-----+-----+-----+-----+-----+------+
| id | item_id | shipping | delivery |
======================================
| 1 | 1 | YES | NO |
======================================
======================================
| 2 | 2 | YES | YES |
======================================
| 3 | 2 | YES | YES |
======================================
| 4 | 2 | YES | YES |
======================================
| 5 | 2 | YES | YES |
======================================
======================================
| 6 | 3 | YES | NO |
======================================
| 7 | 3 | YES | YES |
======================================
SELECT * FROM oder_product WHERE shipping=’YES’ AND delivery=’YES’ AND item_id=‘2’;
PHP
If $result=all rows match;
Echo’ All Products match’;
else
Echo’ some products don’t match’;
最佳答案
$sql=SELECT * FROM oder_product WHERE shipping='YES' AND delivery='YES' AND item_id='2';
$result=mysqli_query($con,$sql);
使用 mysqli_num_rows() 查找数字
$rowcount=mysqli_num_rows($result);
if($rowcount>0){
echo 'All Products match';
}
else{
echo 'some products don’t match';
}
关于php - 计算和比较行查询 Mysql PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36138129/