<?php 

require 'db.php';
if(isset($_GET['sid']) && isset($_GET['token']))
{
    $shop_id = $_GET['sid'];
    $shop_code = $_GET['token'];

    include 'token_check.php';
    
    if($token_check)
    {
        $sels = $con->query("select * from queries where shop_id='$shop_id' and shop_code='$shop_code'");
        while($rows = $sels->fetch_assoc())
        {
            $cat =  $con->query("select name,mobile from user where id=".$rows['uid']." and shop_id='$shop_id' and shop_code='$shop_code'");
        	if($row = $cat->fetch_assoc())
        	{
        	    $p['name'] = $row['name'];
                $p['mobile'] = $row['mobile'];
        	}
        	$date = date_create($rows['message_date']);
        	$p['date'] = date_format($date,"d-m-Y");
        // 	$p['date'] = $rows['message_date'];
        	$p['message'] = $rows['message'];
        	$p['status'] = $rows['status'];
        	$cp[] = $p;
        }
        
        echo json_encode($cp);
    }
    else
    {
        $rows = array('status'=>"",'message' => 'Data Error');
        echo json_encode($rows);
    }
}

?>