[英]Total count inside an if of while loop
我试图弄清楚如何在while循环的if循环内执行totalCount,但到目前为止仍未成功
我如何使用此代码达到目标
$rowCount = 1;
while ($clientrows = $statement->fetch()) {
// should return 1000 rows
if ($clientrows['company'] != $current_client) {
echo $rowCount++;
$rowCount++;
// return clientX (one time)
}
if ($clientrows['time'] != NULL ) {
// returns X rows of clientX(from the previews count
// could be any number but lets say here it should be 100 rows
echo $rowCount++;
$rowCount++;
// i need the total counts inside this IF($clientrows['time'] != NULL )
}
echo $rowCount++; // doesn't show anything
// create here the IF total count of previews IF function
// if($totalCounts) {
// echo ' Do something here ';
// }
}
echo $rowCount++; //shows the total rows of while loop while ($clientrows = $statement->fetch())
如果我将count ++放在IF函数之后,如果我在末尾不显示任何内容,那么它将计算所有内容的总和
编辑计数数返回我的while循环的所有行($ clientrows = $ statement-> fetch()(大约1000)),我需要实现的是获取此IF语句的总行
if($ clientrows ['time']!= NULL){}可能是1000行中的100或101或200
救命?
“ ++”是增量。 它将+1加到您的变量中。 等于$ a = $ a +1;
的
echo $rowCount++;
$rowCount++;
写
echo $rowCount;
$rowCount++;
编辑。 我刚刚读了你的脚本评论
//shows the total rows of while loop while ($clientrows = $statement->fetch())
您不能只使用$ statment-> num_rows()吗?
当你做echo $rowCount++;
即使仅回显它,也可以增加$rowCount
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.