如何使用php从mysql中的表中获取多个行...

时间:2015-10-21 09:17:28

标签: php mysql

我有一个表名为p_customer现在我想从表中获取条目数并打印该数量的客户

<?php     
 $wherecat3 = "p_customer_status = 'active' AND `p_customer_id` = '".$catRes['p_customer_id']."' ";
 $catsql3 = $general->GetRows('*' ,' p_customer' ,$wherecat3);         
 $catRes3 = mysql_fetch_row($catsql3);

?>


<p><?=$catRes3;?></p>

2 个答案:

答案 0 :(得分:0)

尝试

$catRes3 = mysqli_num_rows($catsql3);

答案 1 :(得分:0)

您可以使用mysqli_num_rows()获取从Mysql结果中获取的记录数。

<?php
$wherecat3 = "p_customer_status = 'active' AND `p_customer_id` = '" . $catRes['p_customer_id'] . "' LIMIT $n";
$catsql3 = $general->GetRows('*', ' p_customer', $wherecat3);
$n = mysqli_num_rows($catsql3);
$catRes3 = mysql_fetch_row($catsql3);
?>
<p><?= $catRes3; ?></p>
</div>