我在理解下面的代碼行時遇到了一些問題。究竟是什麼做的,它是如何幫助我查詢在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