如何直接从mysql数据库中获取图像并使用php以json格式显示它们。如何做到这一点?

I am developing an android application.For that i need to get data from my server mysql database directly.And i want to display all the images in json format using php code. Kindly some one help me pease.Thanks in advance.

First make sure you have your images in your public_html folder and then use that url in mysql database to retrieve and then encode the obtained results in json format and now use the link to show images in your android application by using base64 conversion.

Here is the code for u

   <?php
   $host="localhost"; //replace with database hostname 
    $username="username"; //replace with database username 
    $password="password"; //replace with database password 
    $db_name="dbname"; //replace with database name

     $con=mysqli_connect("localhost", "username", "password")or die("cannot     connect"); 
     mysqli_select_db($con,"dbname")or die("cannot select DB");
     $sql = "select imagepath from TABLE_NAME"; 

      $result = mysqli_query($con,$sql);
      $json = array();


       if(mysqli_num_rows($result)){
       while($row=mysqli_fetch_assoc($result)){
       $json['Image_Urls'][]=$row;


        }
       print_r(json_encode($json,JSON_PRETTY_PRINT));
       }


        ?>

Your Mysql database should have a column to store the imagepath and that image link should point to your images in folder.

This is the exact solution for the question you asked.