<?php

// array for JSON response

 $con=mysqli_connect("localhost","zuqppzzxft","2XcqRWsZEv","zuqppzzxft") or die("Error Connecting Db gfgf");

mysqli_set_charset($con, "utf8");

$data = array();
 
 

  
   $selected_date = $_POST['selected_date'];

  	$qry = mysqli_query($con,"SELECT p.adname,p.adfrom,p.category,p.app_name,p.app_icon,b.package_name,p.ads_live,b.date_added,b.download_count FROM bhavesh_appdownloads as b,prank_appmaster as p where b.date_added='$selected_date' AND b.package_name=p.package_name ORDER BY b.download_count DESC"); 	
		
					$numrows = mysqli_num_rows($qry);	
			   		for ($i = 0; $i < $numrows; $i++) 
                    {
				     	  $row = mysqli_fetch_array($qry);
					//	  $data[$i] = array("category"=>$row["category"],"app_name"=>$row["app_name"],"app_icon"=>$row["app_icon"], "package_name"=>$row["package_name"], "date_added"=>$row["date_added"], "download_count"=>$row["download_count"]);
						array_push($data, array("adname"=>$row["adname"], "adfrom"=>$row["adfrom"], "category"=>$row["category"],"app_name"=>$row["app_name"],"app_icon"=>$row["app_icon"], "ads_live"=>$row["ads_live"], "package_name"=>$row["package_name"], "date_added"=>$row["date_added"], "download_count"=>$row["download_count"]));
					}
			    
				if(empty($data))
				{
					$data=array("success"=>0, "message"=>"there is no data found...!!");
				}else
				{
				    $data = array( "success"=>1, "data"=>$data);
				}
 
 echo json_encode($data);
?>