shane18 Posted February 7, 2010 Share Posted February 7, 2010 I want to run a while loop that lists the persons groups if the person has groups enabled..... while($GROUP = $GROUPS->fetch_object() && $GROUP_SET == 1){ Why doesn't this work? $GROUP keeps equaling 1... but if I take out the && $GROUP_SET == 1 it doesn't equal 1... Link to comment https://forums.phpfreaks.com/topic/191260-while-loop-problem/ Share on other sites More sharing options...
Buddski Posted February 7, 2010 Share Posted February 7, 2010 You should check to see if they have groups set first if($GROUPS_SET == 1) { while($GROUP = $GROUPS->fetch_object()){ // Do your code } } While loops arent there to check if a variable is set or not.. Link to comment https://forums.phpfreaks.com/topic/191260-while-loop-problem/#findComment-1008432 Share on other sites More sharing options...
shane18 Posted February 7, 2010 Author Share Posted February 7, 2010 That is how I would usually do it, but I'm trying to understand the why if/while statements behave like this... while($GROUP = $GROUPS->fetch_object() && $GROUP_SET == 1){ -Don't Work while($GROUP_SET == 1 && $GROUP = $GROUPS->fetch_object()){ -Works Why does the order of the expressions make a change on whether it works or not? Link to comment https://forums.phpfreaks.com/topic/191260-while-loop-problem/#findComment-1008448 Share on other sites More sharing options...
shane18 Posted February 7, 2010 Author Share Posted February 7, 2010 Sooo, I'm guessing no one knows the answer to my question? Link to comment https://forums.phpfreaks.com/topic/191260-while-loop-problem/#findComment-1008471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.