<?php

require 'db.php';

$i=0;
$sels = $con->query("select uid,p_method,total,datesloat from orders where status = 'completed'");
while($rows = $sels->fetch_assoc())
{
    $cat =  $con->query("select name from user where id=".$rows['uid']);
	if($row = $cat->fetch_assoc())
	{
	    $p['name'] = $row['name'];
	}
	$p['s_no'] = $i+1;
	$p['order_date'] = $rows['datesloat'];
	$p['pay_mode'] = $rows['p_method'];
	$p['amount'] = $rows['total'];
	$cp[] = $p;
	$i++;
}
echo json_encode($cp);

?>