<?php
require 'vendor/autoload.php';

$app = new \Slim\Slim();

$app->get('/{user}', function () {
	$user=$request->getAttribute('user');
	$servername = "182.50.133.88";
	$username = "exam";
	$password = "123456";
	$dbname = "oes_aims";
$item=array();
	// Create connection
	$con = new mysqli($servername, $username, $password, $dbname);
	$result = mysqli_query($con,"SELECT * FROM `tbl_users` where first_name='$user' AND login='Admin'");
	if ($result->num_rows > 0) {
    $items = array();
    // output data of each row
    while($row = $result->fetch_assoc()) 
	{
        $item = array("user_id" => $row['registration_id'],
                                         "Role" => $row['role'],
					  "lastname" => $row['last_name'],
					  "gender" => $row['role'],
					  "dob" => $row['dob'],
					  "address" => $row['address'],
					  "email" => $row['email'],
					  "phone" => $row['phone'],
					  "department" => $row['department'],
					  "category" => $row['category'],
					  "login" => $row['login'],  
					  "avatar" => $row['avatar']
					 );

    }}
	$response=$item;
		echo json_encode($response);
});


$app->run();
