<?php 
	
	require_once '../includes/DbConnects.php';



$db = new DbConnect();
$con = $db -> connect();

// $stmt = $con -> prepare("SELECT username from users where role='User'");
// $stmt->execute();
// $stmt -> bind_result($username);
// $user_array=array();
//  while($stmt -> fetch()){
//  $temp = array();
//  $temp['username'] = $username;
//  array_push($user_array, $temp);
//  }

// foreach ($user_array as $key => $value) {
// 	# code...
// 	 $value['username'];
// 	$usernames = $value['username'];

// $stmt = $con -> prepare("SELECT id,orders,user,day,update_time from orders_made_tb where user = '$usernames' order by update_time desc limit 1");

$stmt = $con -> prepare("SELECT id,orders,user,day,update_time from orders_made_tb where status = 'N' ORDER BY ID,USER,DAY ASC");
$stmt -> execute();
$stmt -> bind_result($id,$meals,$user,$day,$update_time);
$orderCall = array();

// traversing through all the result 
 while($stmt->fetch()){
 $temp = array();
 $temp['id'] = $id;
 $temp['orders'] = $meals;
 $temp['user'] = $user;
 $temp['day'] = $day;
 $temp['update_time'] = $update_time; 
 array_push($orderCall, $temp);
 }
//  // print_r($orderCall); echo "<br/><br/>";
//  //displaying the result in json format 
echo json_encode($orderCall);

// $result = array_merge($orderCall);



 ?>