简体   繁体   English

使用 Volley 和 PHP 和 Z466DEEC76ECDF5FCA6D38571F63 从 Android 中的 MySQL 服务器数据库检索单个数据

[英]Retrieve single Data From MySQL Server DB in Android using Volley and PHP and json

Here PHP code data coming from server but null values how its set everything is works fine without error please explain这里 PHP 代码数据来自服务器,但 null 值它的设置如何正常工作没有错误请解释

if($_SERVER['REQUEST_METHOD']=='GET'){

    $id  = $_GET['id'];

    require_once('dbConnect.php');

    $sql = "SELECT * FROM colleges WHERE id='".$id."'";

    $r = mysqli_query($con,$sql);

    $res = mysqli_fetch_array($r);

    $result = array();

    array_push($result,array(
        "name"=>$res['name'],
        "address"=>$res['address'],
        "vc"=>$res['vicechancellor']
        )
    );

    echo json_encode(array("result"=>$result));

    mysqli_close($con);

}

Change the $sql to the below once and try....将 $sql 更改为以下一次并尝试....

$sql = "SELECT * FROM colleges WHERE id=$id"; $sql = "SELECT * FROM 大学 WHERE id=$id";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM