<?php
function get_teacher_classes($teacher_id){
include "application/config/database.php";

$hostname = $db['default']['hostname'];
$username = $db['default']['username'];
$password = $db['default']['password'];
$database = $db['default']['database'];
$dbdriver = $db['default']['dbdriver'];

// Create connection
$conn_db = mysqli_connect($hostname, $username, $password, $database);
// Check connection
$connected = 0;
			if (!$conn_db) {
				die("Connection failed: " . mysqli_connect_error());
			}

//$sql2 = "SELECT * from `class_sections` WHERE class_id='$class_id' AND section_id='$section_id' ORDER BY `id` DESC LIMIT 1;";
$data_array = array();	
$update_select_sql="SELECT class_sections.id,class_sections.teacher_id, classes.id as class_id, classes.class,class_sections.section_id, sections.section
FROM class_sections
INNER JOIN classes ON class_sections.class_id=classes.id
INNER JOIN sections ON class_sections.section_id=sections.id
WHERE class_sections.teacher_id = $teacher_id;";
$obj ="";
	if ($result_update= mysqli_query($conn_db, $update_select_sql))
	{	
		$serial = 1;		
		if(mysqli_num_rows($result_update)>0){
			while ($obj=mysqli_fetch_assoc($result_update))
			{
				//////to GLOBAL				
				$type = $obj;
				$a=$type;
				$value_name = array_keys($a);
				$posts = $value_name;
				foreach ($posts as $value) 
							{///
								$name = $value;	
								$$value =$type[$name];
								$value = $type[$name];
							$data_array[$serial][$name] = $value;
							}
				$serial++;
			}	
		}
	}
//	echo "<pre>". print_r($data_array) . "</pre>";
return $data_array;

	}	
?>