This question already has answers here:
Display single column value of mysqli query
                                
                                    (3个答案)
                                
                        
                                3年前关闭。
            
                    
这是我的查询:

$qry1 = "SELECT COUNT('name') FROM `brands` WHERE `catagory_id` = '".$id."';";
$res = mysqli_query($conn, $qry1);


我想要count的值,并想在另一个查询中使用它。那怎么可能?

最佳答案

尝试;

$qry1 = "SELECT COUNT(name) as counts FROM brands WHERE catagory_id = '".$id."';";
$res = mysqli_query($conn, $qry1);
$row = mysqli_fetch_array($res);
$count = $row["counts"];


现在,此$ count变量保存该值。您可以在其他查​​询中包含此变量。

关于php - 我想要count的值,并想在其他查询中使用它。那怎么可能? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36219829/

10-11 06:59