本文介绍了循环不递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿我正在尝试为我的查询中的行数做一个循环。



$ query3 =SELECT * FROM carrinho where utilizador =' $ utilizador';

$ res1 = mysqli_query($ lig,$ query3);

$ num = mysqli_num_rows($ res1);





for($ i = 0; $ i< $ num; $ i ++){

$ query5 =SELECT * from carrinho其中id_carrinho ='$ i';

$ res3 = mysqli_query($ lig,$ query5);

$ num1 = mysqli_num_rows($ res3);



我尝试了什么:



我试图回显行数确定有行,它返回2.



但是当我尝试回显$ i时它返回0.

解决方案




Hey i'm trying to do a for cycle for the number of rows from my query.

$query3="SELECT * FROM carrinho where utilizador = '$utilizador'";
$res1=mysqli_query($lig,$query3);
$num = mysqli_num_rows($res1);


for ($i = 0; $i < $num; $i++) {
$query5 = "SELECT * from carrinho where id_carrinho = '$i'";
$res3=mysqli_query($lig,$query5);
$num1=mysqli_num_rows($res3);

What I have tried:

I tried to echo the number of rows to be sure there are rows, it returns 2.

But when i try to echo $i it returns 0.

解决方案




这篇关于循环不递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 02:15