我在理解下面的代码行时遇到了一些问题。究竟是什么做的,它是如何帮助我查询在AndroidAndroid查询外部MySQL数据库
$q=mysql_query("SELECT * FROM people WHERE birthyear>'".$_REQUEST['year']."'");
while($e=mysql_fetch_assoc($q))
$output[]=$e;
print(json_encode($output));
我知道初始部分的数据库就意味着选择表的人那里birthyear每个记录......
不过,我以后困惑了。我从Android使用http调用这个php函数post
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("year","1980"));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/retrieve.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
输入流在哪里。有人可以帮我吗?
我想知道的是,php代码如何知道一年以上的值,它应该返回ID – user1092042 2012-03-13 12:31:23
@ user1092042'NameValuePair'是用'name = year'和'value = 1980'创建的。该NameValuePair作为POST参数传递给PHP代码。我用一段描述这个的段落更新了我的答案。 – 2012-03-13 12:49:48
谢谢,我现在明白了 – user1092042 2012-03-13 12:51:48