我想将参数发送到`php`脚本,以便它可以正确过滤

时间:2015-05-19 13:33:38

标签: java php android

我有一个需要带两个参数的php脚本:

if (isset($_GET["category"]) && isset($_GET["book"])) {
    $category= $_GET['category'];
    $book= $_GET['book'];
    $result = mysql_query("SELECT * FROM colection WHERE category='$category' AND book='$book'");
//rest of the code
}

我使用Intent将数据从活动传递到第三个活动:

 Intent passedCategory =getIntent();
 String vCategory = passedCategory.getStringExtra("category");
 Intent passedBook =getIntent();
 String vBook = passedBook.getStringExtra("book");

来自此tutorial我使用ServiceHandler.java进行http来电,我修改了MainActivity.java(来自同一个tutorial)使用。更改很小,例如XML文件的名称,class名称等等。我想我需要在doInBackgroundmakeServiceCall(URL,ServiceHandler.GET, HERE))中以某种方式添加参数:

protected Void doInBackground(Void... arg) {
// Intent from above
ServiceHandler serviceClient = new ServiceHandler();
Log.d("url: ", "> " + URL);
String json = serviceClient.makeServiceCall(URL,ServiceHandler.GET);
Log.d("Get colections response: ", "> " + json);
if (json != null) {
//rest of the code 
}
}

我想将参数发送到php脚本,以便它可以正确过滤,我该怎么做?

0 个答案:

没有答案