Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to select images from database and show on page

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 225
    Comment on it

    Hello Reader's! If you have stored the image in database as blob. Then you need a php code to retrieve them and a html page to show them. Lets see an example below how to show them

    First create a php page getImage.php and code as written below:-

    <?php
    
      $id = $_GET['id'];
      $link = mysql_connect("localhost", "root", "");
      mysql_select_db("dvddb");
      $sql = "SELECT dvdimage FROM dvd WHERE id=$id";
      $result = mysql_query("$sql");
      $row = mysql_fetch_assoc($result);
      mysql_close($link);
    
      header("Content-type: image/jpeg");
      echo $row['dvdimage'];
    ?>
    

    Now create html page and make php code to call your image :-

    <body>
    <img src="getImage.php?id=1" width="175" height="200" />
    </body>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: