ArrayList<NameValuePair> dataToSend = new ArrayList<>();
dataToSend.add(new BasicNameValuePair("email", email));
try{
HttpParams httpRequestParams = getHttpRequestParams();
HttpClient client = new DefaultHttpClient(httpRequestParams);
HttpPost post = new HttpPost(SERVER_ADDRESS + "display_userAdvertisement.php");
post.setEntity(new UrlEncodedFormEntity(dataToSend));
client.execute(post);
我的PHP代码
php
$con=mysql_connect('localhost','synaptic','12345');
//define ('DB_HOST', 'xxx.xx.xxx.xx:80');
mysql_select_db("bruhbmvr_register",$con);
$email = $_POST['email'];
$sql = "select * from post_ads WHERE email = '$email'";
$result = mysql_query($sql);
$json = array();
if(mysql_num_rows($result)){
while($row=mysql_fetch_assoc($result)){
$json['userinfo'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);
?>
我试图将Android应用中的电子邮件解析为PHP文件,但它是空的。
我的问题是如何将电子邮件解析为PHP,然后直接以JSON格式显示电子邮件的详细信息?