<?php 

require 'db.php';

$sels = $con->query("select * from rider");
while($rows = $sels->fetch_assoc())
{
    $p['id'] = $rows['id'];
	$p['name'] = $rows['name'];
	$p['mobile'] = $rows['mobile'];
	$p['email'] = $rows['email'];
	$p['status'] = $rows['status'];
	$cat =  $con->query("select count(rid) as rids from orders where rid=".$rows['id']." and r_status = 'delivered'");
	if($row = $cat->fetch_assoc())
	$p['orders'] = $row['rids'];
	$p['a_status'] = $rows['a_status'];
	$cp[] = $p;
}

echo json_encode($cp);
?>