无法获得array_push的输出

时间:2016-05-26 15:19:13

标签: php mysqli array-push

我正在研究从PHP文件中显示SQL表格输出的Android应用程序,问题是这个PHP文件在输出中不会显示任何内容。

我试图在整个互联网上找到解决方案但找不到任何解决方案。

这是源代码:

<?php

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

    $email = $_POST['user_email'];

    require_once 'DB_Connect.php';
    $db = new DB_Connect();

    $response = array();

    $sql = ("SELECT * FROM white_list WHERE user_email = '" . $email . "'");
    $result = mysqli_query($db->connect(), $sql) or die(mysqli_error());

    $no_of_rows = mysqli_num_rows($result);

    if ($no_of_rows > 0) {
        $response["white_list"] = array();

        while ($row = mysqli_fetch_array($result)) {
            $white_list            = array();
            $white_list["name"]    = $row["wl_name"];
            $white_list["hp"]      = $row["wl_hp"];
            $white_list["address"] = $row["wl_address"];
            $white_list["link"]    = $row["wl_link"];

            array_push($response["white_list"], $white_list);
        }
        $response["success"] = 1;
        echo json_encode($response);
    } else {
        $response["success"] = 0;
        $response["message"] = "No Data";

        echo json_encode($response);
    }
}

0 个答案:

没有答案