PHP my admin データベースから画像を取得し、Android リスト ビューに表示するにはどうすればよいですか? 名前とIDを取得するための次のスクリプトがあります。しかし、画像を取得する方法もわかりません。同じクエリを使用して画像を取得するにはどうすればよいですか?
<?php
/*
Our "config.inc.php" file connects to database every time we include or require
it within a php script. Since we want this script to add a new user to our db,
we will be talking with our database, and therefore,
let's require the connection to happen:
*/
require("config.php");
//initial query
$query = "Select * FROM channels";
//execute query
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error!";
die(json_encode($response));
}
// Finally, we can retrieve all of the found rows into an array using fetchAll
$rows = $stmt->fetchAll();
if ($rows) {
$response["success"] = 1;
$response["message"] = "Post Available!";
$response["posts"] = array();
foreach ($rows as $row) {
$post = array();
$post["channelname"] = $row["channelname"];
$post["channelid"] = $row["channelid"];
//update our repsonse JSON data
array_push($response["posts"], $post);
}
// echoing JSON response
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No Channel Available!";
die(json_encode($response));
}
?>