Hi all, I've errors in my code and i'm unsure whether the way i loop is in a correct method. Pls give me some guidance as it is very important to me. Thank!

Error i got-> Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\FYP\assign_venueTest.php on line 118

<?php
	$class_id = $_GET['id'];
	$HOST = 'localhost';
	$USERNAME = 'root';
	$PASSWORD = '';
	$DB = 'sjas';
	$link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB);
	
	//get class
	$sql1 = "SELECT * FROM class,course WHERE idClass = $class_id and Course_idCourse = idCourse";
	$result1 = mysqli_query($link,$sql1) or die(mysqli_error($link));
	$row1 = mysqli_fetch_array($result1);
	
	//get students
	$sql2 = "SELECT * FROM member m,attendance a WHERE Class_idClass = $class_id and Member_idMember = idMember group by idMember";
	$result2 = mysqli_query($link,$sql2) or die(mysqli_error($link));
	$no_student = mysqli_num_rows($result2);
	$student_name = mysqli_fetch_array($result2);
	
	//Get information of assigning class
	$assigning = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance, class where Venue_idVenue IS NULL and Class_idClass = $class_id group by Class_idClass";
	$assigning_result = mysqli_query($link,$assigning) or die(mysqli_error($link));
	$assigning_no = mysqli_num_rows($assigning_result);
	$assigning_venue = mysqli_fetch_array($assigning_result);
	
	//For Assigning Day duration
	$assigning_day = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 1 group by Class_idClass";
	$assigning_day_result = mysqli_query($link,$assigning_day) or die(mysqli_error($link));
	$assigning_day_no = mysqli_num_rows($assigning_day_result);
	$assigning_venue = mysqli_fetch_array($assigning_day_result);
	
	//For Assigning Night duration
	$assigning_night = "Select Class_idCLass,Venue_idVenue,idVenue, idTime_Slot from attendance, class, time_slot, venue where Venue_idVenue IS NULL and Class_idClass = $class_id and idTime_Slot = 2 group by Class_idClass";
	$assigning_night_result = mysqli_query($link,$assigning_night) or die(mysqli_error($link));
	$assigning_night_no = mysqli_num_rows($assigning_night_result);
	$assigning_venue = mysqli_fetch_array($assigning_night_result);
	
	//Get Assigned Venue's information
	$assigned = "Select Class_idCLass,Venue_idVenue,day01,day02,day03,day04,day05,day06,day07,day08,day09,day10,day11,day12 from attendance a,class c where a.Class_idClass is not Null and a.Venue_idVenue is not Null Group by Class_idClass";
	$assigned_result = mysqli_query($link,$assigned) or die(mysqli_error($link));
	$assigned_venue = mysqli_fetch_array($assigned_result);
	$assigned_venue_no = mysqli_num_rows($assigned_result);
	echo $assigned_venue_no;
	
	//For Assigned Day duration
	$assigned_day = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 1 and Time_Slot_idTime_Slot = idTime_Slot 
		 and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_day_result = mysqli_query($link,$assigned_day) or die(mysqli_error($link));
	$assigned_day_array = mysqli_fetch_array($assigned_day_result);
	$assigned_day_row = mysqli_num_rows($assigned_day_result);
	
	//For Assigned Night duration
	$assigned_night = "Select Class_idClass,Venue_idVenue,idTime_Slot from attendance, class, time_slot WHERE Class_idClass = idClass and idTime_Slot = 2 and Time_Slot_idTime_Slot = idTime_Slot 
		 and Venue_idVenue IS NOT Null GROUP BY Class_idClass";
	$assigned_night_result = mysqli_query($link,$assigned_night) or die(mysqli_error($link));
	$assigned_night_array = mysqli_fetch_array($assigned_night_result);
	$assigned_night_row = mysqli_num_rows($assigned_night_result);

?>	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Assign Class</title>
	</head>
	<body>
			<form name="s1" action="assign_lecturer.php"  method="post">
	
			<h1>Assign Venue</h1>
			<?php
				echo 'Course: '.$row1['name'].'';
				echo '<br/>';
				echo 'Class: '.$class_id.'';
				echo '<input type="hidden" name="class_id" value="'.$class_id.'"/>';
				echo '<input type="hidden" name="no_student" value="'.$no_student.'"/>';

				echo'<table cellpadding="10" border="1" style="border-collapse: collapse">';
				
				echo'<tr>
						<th>students</th>
						<th>Venue</th>
					</tr>';
			
				$venue_no = 1;
				$member_no =1;			
				
				If ($assigning_no == 1)
				{
					for ($i=1; $i<=$no_student; $i++)
					echo '<tr>';
					echo '<td><input type="hidden" name="select_member'.$member_no.'" value="'.$student_name['idMember'].'" />'.$student_name['name'].'</td>';
					
					echo '<td>';
					//check day availabilty
					while ($assigned_venue_no){
					
						//assigned day 1-9
						for ($i=1; $i<=9; $i++){
							if($assigned_venue['day0'.$i] != '')
						{
							$assigned_date[$i] = $assigned_venue['day0'.$i];
							//store assigned venue
							$venue_assigned[$i] = $assigned_venue['Venue_idVenue'];
						}
					}
						//assigned day 10-12	
						for ($i=10; $i<=12; $i++){
							if($assigned_venue['day'.$i] != '')
						{
							$assigned_date[$i] = $assigned_venue['day'.$i];
							//store assigned venue
							$venue_assigned[$i] = $assigned_venue['Venue_idVenue'];
						}
					}
						//assigning day 1-9	
						for ($k=1; $k<=9; $k++){
							if($assigning_venue['day0'.$k] != '')
						{
							$assigning_date[$k] = $assigning_venue['day0'.$k];
					
						}
					}
						//assigning day 10-12
						for ($k=10; $k<=12; $k++){
							if($assigning_venue['day'.$k] != '')
						{
							$assigning_date[$k] = $assigning_venue['day'.$k];
							//echo $assigning_date[$k];
						}
					}
			
					if ($assigned_date[$i] != $assigning_date[$k]){
						//echo 'Hello!';
				
						//Check day duration
						for($l=1;$l<=$assigning_day_row;$l++){
				
							$day_result[$l] = $assigned_day_row['Venue_idVenue'.$l];
					
					
								if ($day_result[$l]!= $venue_assigned[$i])
						
								{	
									$venue_used[$l] = $assigned_day_array['idVenue'.$l];
									$sql3 = "Select * from Venue where idVenue != $venue_used[$l]";
									$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  
								{
									for($m=1;$m<=$assigning_night_row;$m++){
									$night_result[$m] = $assigned_night_row['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
											{
												$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>';
											}
										}
								}
						
							}
						}
					}
					echo'</select>
					</td>
					</tr>';	
					echo '</table>';
				}
					
				
			?>
			</form>
	</body>		
</html>

For a start, the $assigning_night_row variable used on line 155 isn't being set anywhere in the code that you provided.

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.