<?php 

require 'db.php';

$sels = $con->query("select * from user");
while($rows = $sels->fetch_assoc())
{
    $p['id'] = $rows['id'];
	$p['name'] = $rows['name'];
	$p['mobile'] = $rows['mobile'];
	$p['email'] = $rows['email'];
	$cat =  $con->query("select count(uid) as uids from orders where uid=".$rows['id']." and status = 'completed'");
	if($row = $cat->fetch_assoc())
	$p['total_orders'] = $row['uids'];
	$p['status'] = $rows['status'];
	$cp[] = $p;
}

echo json_encode($cp);
?>