小编ZXi*_*gIT的帖子

在Spinner外面单击关闭微调器

我想在Spinner外部点击后关闭一个Android微调器.这甚至可能吗?

android onclick spinner

13
推荐指数
1
解决办法
6626
查看次数

从Android传递JSONArray到PHP

我已经阅读了许多关于PHP和JSONArray循环的其他问题.我正在通过我的Android设备向他们的班级和studentId发送不同学生的JSONArray值.使用这些值,我在数据库中搜索它们的名称并返回一个JSONArray.

JSON Input: [{"studentId":"2","class":"2a","dbname":"testDb"}]
<?php

 $jsonString = $_POST['json'];  //see comment below

 $jArray = json_decode($jsonString, true);

 $conn = mysql_connect('localhost', 'user', 'pwd' );

mysql_select_db('dbname', $conn);

foreach( $jArray as $obj ){
    $className = $obj['class'];   //String
    $id= $obj['studentId'];       //int

    $result = mysql_query("SELECT name FROM student WHERE class='$className' AND id='$id'");

    $e=mysql_fetch_assoc($result);    //will only fetch 1 row of result
    $output[]=$e;


}

      echo (json_encode($output));

?>
Run Code Online (Sandbox Code Playgroud)

Android的

HttpClient client = new DefaultHttpClient();
HttpResponse response;
try{
 HttpPost post = new HttpPost("http://abc/getName.php");
 List<NameValuePair> nVP = new ArrayList<NameValuePair>(2);  
 nVP.add(new BasicNameValuePair("json", studentJson.toString())); …
Run Code Online (Sandbox Code Playgroud)

php arrays android json

4
推荐指数
1
解决办法
6848
查看次数

标签 统计

android ×2

arrays ×1

json ×1

onclick ×1

php ×1

spinner ×1