如何在Android Studio上使用Shimmer获取数据MySQL

时间:2018-07-20 09:52:01

标签: php android android-studio android-fragments

Sample Image Sample Image Sample Image

当我在手机上运行时,它无法在数据库sql中获取数据“无法获取菜单!请重试。”

这是我的php代码:

<?php 

require_once "../include/Constants.php";

$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    $stmt = $conn->prepare("SELECT id, name, description FROM newsfeed");

    $stmt->execute();

    $stmt->bind_result($id, $name, $description);

    $newsfeed = array(); 

    //traversing through all the result 
    while($stmt->fetch()){
        $temp = array();
        $temp['id'] = $id; 
        $temp['name'] = $name; 
        $temp['description'] = $description; 
        array_push($newsfeed, $temp);
    }

    //displaying the result in json format 
    echo json_encode($newsfeed);

1 个答案:

答案 0 :(得分:0)

您写的是newsFeedDataList != null,而不是您写的

if (newsFeedDataList == null){
return ;
}