Jump to content

problem with while


hno

Recommended Posts

 

 

HI

I have a while and there is a forrach in that loop and it's something like this:

while($row=mysqli_fetch_assoc($r)){

//some codes

foreach($row['cat'] as $key=>$val){

//some codes

}

}

 

But the while loop run just one time and i'm sure it should run more than one time .I know my problem is with foreach because when i remove the foreach loop the while work well.How should solve this problem/

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/183296-problem-with-while/
Share on other sites

why are you using the foreach?  what is its purpose?

 

they are both looping functions, so you should really have a good reason for embedding them.  and seeing as how $row['cat'] is not an array, you are using foreach() out of context.

 

so, explain what it is you're trying to do.

Link to comment
https://forums.phpfreaks.com/topic/183296-problem-with-while/#findComment-967516
Share on other sites

why are you using the foreach?  what is its purpose?

 

they are both looping functions, so you should really have a good reason for embedding them.  and seeing as how $row['cat'] is not an array, you are using foreach() out of context.

 

so, explain what it is you're trying to do.

the foreach is  for the rows that fetched and run in the while and i need it .

Link to comment
https://forums.phpfreaks.com/topic/183296-problem-with-while/#findComment-967601
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.