How to retrieve an images from PHp myadim database and display in android list view? -
how retrieve images php admin database , display in android list view? have following script retrieve name , id. don't know how retrieve image well. how retrieve image using same query?
<?php /* our "config.inc.php" file connects database every time include or require within php script. since want script add new user our db, talking our database, , therefore, let's require connection happen: */ require("config.php"); //initial query $query = "select * 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, can retrieve of found rows array using fetchall $rows = $stmt->fetchall(); if ($rows) { $response["success"] = 1; $response["message"] = "post available!"; $response["posts"] = array(); foreach ($rows $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)); } ?>
most likely, each $row array have fields. 1 of these might url or path images; can use
print_r($row)
or
var_dump($row)
in block below
foreach ($rows $row) { ... }
to see other data held within arrays.
finally, should include data in $response array.
Comments
Post a Comment