【发布时间】:2018-07-20 09:52:00
【问题描述】:
当我在手机上运行时,它没有在我的数据库中获取数据 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);
【问题讨论】:
-
不要发布代码截图。相反,写一个minimal reproducible example 并将其作为您问题的一部分发布。
标签: php android android-studio android-fragments