我正在尝试从 base64 编码的表格行中提取图片。我需要对它们进行解码并显示在网页上。我真的很想把它们放到幻灯片中,但那是另一个话题!
这是到目前为止的查询
<?php
require("config.inc.php");
//initial query
// table name is pictures and table row is picture
$query = "Select * FROM pictures";
//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"] = "Photos Available!";
$response["posts"] = array();
// only 3 rows in table - post_id, username, picture
foreach ($rows as $row) {
$post = array();
$post["post_id"] = $row["post_id"];
$post["username"] = $row["username"];
$post["picture"] = $row["picture"];
//update our repsonse JSON data
array_push($response["posts"], $post);
}
// echoing JSON response
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No Photos Available!";
die(json_encode($response));
}
?>
问题是解码它。这是到目前为止显示的内容
http://www.photosfromfriends.com/webservice/gallery.php
这仅适用于一张图片(帖子) 该表格中可能有 50 张图片,每张都需要显示(因此需要幻灯片)。这超出了我的想象,我非常感谢任何帮助。