Hi i am using php to connect my android app to mysql but the get method is not passing the value to the php file.
This is my code.
private void executeAjaxRequest(){
String url = mDataUrl+"?request="+mRequest+"&outlet_id="+mOutletID;
Log.v("url",url);
System.out.println("This is StoreActivity " +url);
AsyncHttpClient httpclient = new AsyncHttpClient();
httpclient.get(url, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
setOutletData(response);
Log.i("TAG",response);
}
});
}
It should pass the outletid and mrequest to the php file to get the data from the database.
Can you tell me where i am going wrong.
error_reporting(0);
//$url = $_GET['url'];
$mR = $_GET["mRequest"];
$mOid = $_GET["mOutletID"];
//$mloc = $_GET['mLocation'];
//connect to the db
//echo $mOid;
$user = "root";
$pswd = "";
$db = "recommendations_db";
$host = "localhost";
$conn = mysql_connect($host, $user, $pswd);
mysql_select_db($db);
//if($mR == 'outlets' && $mloc = 'all'){
$query = "SELECT outlet_id,outlet_name,outlet_location,outlet_image FROM outlets WHERE outlet_id = '$mOid'";
$result = mysql_query($query) or die("Unable to execute query because : " . mysql_error());
//echo $result ." ". $mOid;
while($row = mysql_fetch_assoc($result))
{
$query2 = "SELECT a.item_id,a.item_name,a.item_image FROM items a,outlets b,recommendations c WHERE a.item_id = c.item_id AND b.outlet_id = c.outlet_id AND b.outlet_id = ".$row['outlet_id'];
$row['recommended_products']=array();
$result2 = mysql_query($query2) or die("Unable to execute query because : " . mysql_error());
//echo $row;
while($row2 = mysql_fetch_assoc($result2)){
$row['recommended_products'][]=$row2;
//echo $row;
}
$output[] = $row;
}
print( json_encode($output) );
mysql_close($conn);