Hi, i have problem regarding my code. I using alot of for loop and while loop. However, its been to be one of the while loop is hindering the first loop.

Here my code.

Do{
						//assigned day 1-9
						for ($i=1; $i<=9; $i++){
										
						echo '<option>Hi</option>';
							if($assigned_venue['day0'.$i] != ''){
						
							$assigned_date[$i] = $assigned_venue['day0'.$i];
							//store assigned venue
							$venue_assigned[$i] = $assigned_venue['Venue_idVenue'];
							
							
							echo 'TESTA:'.$assigned_date[$i];
							//echo '<br>';
							//echo '<option>'.$venue_assigned[$i].'</option>';
							//echo '<br>';
							
								//assigning day 1-9	
								for ($k=1; $k<=9; $k++){
									if($assigning_venue['day0'.$k] != '')
								{
									$assigning_date[$k] = $assigning_venue['day0'.$k];
									//echo 'TESTC:'.$assigning_date[$k];
								}
									
									if ($assigned_date[$i] == $assigning_date[$k]){
									//echo 'Hello!';
						
									
									do {
										$day_result = $assigned_day_array['Venue_idVenue'];
										echo $day_result;
										}
									while($assigned_day_array = mysqli_fetch_array($assigned_day_result));
	
									//Check day duration
									for($l=1;$l<=$assigned_day_row;$l++){		
											
											if (($day_result) != ($venue_assigned[$i]))
											
											{
											echo 'DEBUGA:'.$day_result.'<br>';
												//echo 'HEllo1';
												//echo '<option>'.$day_result.'</option>';
												//echo $venue_assigned[$i];
												/*$sql3 = "Select * from Venue where ";
												
												for($g=1;$g<=$assigned_day_row;$g++){
												$sql3 = $sql3." idVenue != $day_result ";
												$sql3 = $sql3." and";
												}
												
												//echo '<option>'.$sql3.'</option>';
												$result3 = mysqli_query($link,$sql3) or die(mysqli_error($link));
												$row3 = mysqli_fetch_array($result3);
												//echo 'TEST1'.$row3['name'];
												//echo' <option name="venue">'.$row3['name'].'</option>';*/
												
											}
											else  
											{
												//Check Night Duration
												for($m=1;$m<=$assigned_night_row;$m++){
												$night_result[$m] = $assigned_night_array['Venue_idVenue'.$m];
												
													if ($night_result[$m]!= $venue_assigned[$i])
													{
														$venue_used[$m] = $assigned_night_array['idVenue'.$m];
														//$sql4 = "Select * from Venue where idVenue != $venue_used[$m]";
														$result4 = mysqli_query($link,$sql4) or die(mysqli_error($link));
														$row4 = mysqli_fetch_array($result4);
														//echo 'TEST2'.$row4['name'];
														//echo' <option name="venue">'.$row4['name'].'</option>';
													}
													else
														//else display the remainding venue
														{
															$sql5 = "Select * from venue";
															$result5 = mysqli_query($link,$sql5) or die(mysqli_error($link));
															$row5 = mysqli_fetch_array($result5);
															//echo 'Test3'.$row5['name'];
															//echo' <option name="venue">'.$row5['name'].'</option>';
														}
													}
											}
									
										}
							
									}
									
								}	
							}
						}

The do while loop in line 30 seems to hinder the main do while loop.
expected result for $day_result is 1 and 4.
If i remove the do while loop, the value of $day_result only return 4. why is that so?

I need this badly, will appreciate for help. Thanks in Advance

Please explain the program Flow...

means... What you want to do with this program???

Oh. I have a set of data. Require filtering. I need to select data from venue which are not used for any days and time.

The code above is help me to filter the data, the whole code for the page is very lengthy, therefore i only paste out the code with the problem.

Anyone can help? this is urgent to me!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.