<?php
// Include the database connection file
include('last_db_config.php');

if (isset($_POST['GovID']) && !empty($_POST['GovID'])) {

$gov=$_POST['GovID'];

$query = "SELECT * FROM edara WHERE GovID = $gov"; 
$result = mysqli_query($conn,$query);

$output = '<option value="">اختر الادارة</option>';

if ($result->num_rows > 0) {
	//echo '<option value="">Select State</option>'; 
	while ($row = $result->fetch_assoc()) {
		$output .= '<option value="'.$row['EdaraID'].'">'.$row['EdaraName'].'</option>';  
	}
	echo $output;
} 

} elseif(isset($_POST['EdaraID']) && !empty($_POST['EdaraID'])) {


$edara=$_POST['EdaraID'];

$query = "SELECT * FROM school WHERE EdaraID = $edara"; 
$result = mysqli_query($conn,$query);

$output = '<option value="">اختر المدرسة</option>';

if ($result->num_rows > 0) {
	//echo '<option value="">Select State</option>'; 
	while ($row = $result->fetch_assoc()) {
		$output .= '<option value="'.$row['SchoolID'].'">'.$row['SchoolName'].'</option>';  
	}
	echo $output;
} 
}
?>