<?php


##########################################################
##@desc The is the search files that queris the database base on mda or cheif seravant
##@file_name: search.php
##@author: Abdulkadir Suleiman Lapai
##@date_created: 23/01/2014
##@date_modified: 8/2/2014
###########################################################






//include the headers resources
require_once('includes/functions.php');



//get user
//$user = get_user();

////get user mda
//$user_mda = get_usermda($user);


//get user role
//$user_role = get_userrole($user);


if (isset($_GET['term']))
{
	$return_arr = array();
	
	
	//query the database for full list
		$query = "SELECT * FROM students WHERE number LIKE '%".$_GET['term']."%'
				 ORDER BY number LIMIT 5";
		
	
				  
				  
	$result = mysqli_query($dbc,$query);
	
	if(mysqli_num_rows($result)>0)
	{
		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			 $return_arr[] =  $row['number'];
			
		}
		
	}
	
	
	 /* Toss back results as json encoded array.*/ 
    echo json_encode($return_arr);
}//end of if



?>






