<?php
	include ("config.php");

	//print_r($_POST);
	$i=0;
	$condition="";
	while($_POST["val$i"]!="")
	{
	 $r[$i]=htmlspecialchars(trim($_POST["val$i"]));
	 
	 if($condition=="")
	 {
	   $condition=$condition.' StopName="'.$r[$i].'"';
	 }
	 else
	 {
	   $condition=$condition.' OR StopName="'.$r[$i].'"';
	 }
	 $i++;
	}
	$newbusno=htmlspecialchars(trim($_POST["newbusno"]));
	
   $update_staff_quer='UPDATE staff SET BusNumber="'.$newbusno.'" WHERE'.$condition;
   $update_student_quer='UPDATE student SET BusNumber="'.$newbusno.'" WHERE'.$condition;
   $update_stop_quer='UPDATE stop SET BusNumber="'.$newbusno.'" WHERE'.$condition;
   mysql_query($update_staff_quer);
   mysql_query($update_student_quer);
   mysql_query($update_stop_quer);
   echo"Done";
   //echo"$update_staff_quer<br>$update_student_quer<br>$update_stop_que";
   
//	if(mysql_num_rows($ans)<=0)

//	{
//	  echo "nobus";
//	  exit();
//	} 
//	else
//	{
//		$Bus_No=$res['BusNumber'];
//    } 
//
//    if(mysql_num_rows(mysql_query($ans))>0)
//      {
//	   echo "yes"; //Employee Number all ready exists
//	   }
//	else
//		{
//		echo "no"; //New Employee student details
//		//now set the session from here if needed
//		//$_SESSION['u_name']=$user_name; 
//		$addClient  = "INSERT INTO staff(EmployeeId,Name,Department,TeleNo,Gender,BusNumber,StopName,Status) VALUES ('$Employee_ID','$Name','$Department','$Telephone_No','$Gender','$Bus_No','$Boarding_Point','1')";
//    mysql_query($addClient) or die(mysql_error());
//	}

?>