php脚本只在android studio中显示一行数据而不是很多

我想问一下如何显示多行数据而不是一行.以下代码显示一行记录而不是多条记录.我在这里使用mysqli_prepare语句.或问题是我的android studio编码?我的应用程序使用登录功能和编码实现如下.

<?PHP
$host="DB_HOST";
$user="DB_USER";
$password="DB_PASSWORD";
$db="DB_NAME";

$con = MysqLi_connect($host,$user,$password,$db);

$parentic=$_POST["ParentIC"];
$password=$_POST["Password"];

$selectquery = MysqLi_prepare($con, "SELECT Parents_Data.Name, Student_List.StudName, Student_List.StudIC, Student_List.Form,Student_List.Class,discipline_record.Date,discipline_record.RulesCode, discipline_record.TypesofMistakes,discipline_record.Punishment FROM discipline_record LEFT JOIN Student_List ON discipline_record.StudIC = Student_List.StudIC LEFT JOIN Parents_Data ON Student_List.ParentIC = Parents_Data.ParentIC WHERE Parents_Data.ParentIC = ? AND Parents_Data.Password = ? ");
MysqLi_stmt_bind_param ($selectquery, "ss", $parentic, $password);
MysqLi_stmt_execute($selectquery);

MysqLi_stmt_store_result($selectquery);
MysqLi_stmt_bind_result($selectquery,$name,$studname,$studic,$form,$classs,$ddate,$code,$mistakes,$punishment);

$user = array();



while(MysqLi_stmt_fetch($selectquery))
{
    $user[name]=$name;
    $user[studname]=$studname;
    $user[studic] = $studic;
    $user[form]=$form;
    $user[classs]=$classs;
    $user[ddate]=$ddate;
    $user[code]=$code;
    $user[mistakes]=$mistakes;
    $user[punishment]=$punishment;            


}

    echo json_encode($user);

    MysqLi_stmt_close($selectquery);


MysqLi_close($con);

?>                          

解决方法:

我会选择这样的东西:

$userGroup = array();
$user = array();

while(MysqLi_stmt_fetch($selectquery))
{
    $user[name]=$name;
    $user[studname]=$studname;
    $user[studic] = $studic;
    $user[form]=$form;
    $user[classs]=$classs;
    $user[ddate]=$ddate;
    $user[code]=$code;
    $user[mistakes]=$mistakes;
    $user[punishment]=$punishment;

array_push($userGroup,$user);            


}

echo json_encode($userGroup);

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...