hno Posted November 29, 2009 Share Posted November 29, 2009 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 More sharing options...
MisterWebz Posted November 29, 2009 Share Posted November 29, 2009 <?php while($row=mysqli_fetch_assoc($r)){ //code } foreach($row['cat'] as $key=>$val){ //code } ?> Link to comment https://forums.phpfreaks.com/topic/183296-problem-with-while/#findComment-967491 Share on other sites More sharing options...
hno Posted November 29, 2009 Author Share Posted November 29, 2009 <?php while($row=mysqli_fetch_assoc($r)){ //code } foreach($row['cat'] as $key=>$val){ //code } ?> NO it's not possible .I should be in the while to extract some values from each row Link to comment https://forums.phpfreaks.com/topic/183296-problem-with-while/#findComment-967508 Share on other sites More sharing options...
mrMarcus Posted November 29, 2009 Share Posted November 29, 2009 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 More sharing options...
hno Posted November 29, 2009 Author Share Posted November 29, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.