My question is regarding this answer. Bootstrap open image in modal
How can I display images that's src comes from MySQL database?
My question is regarding this answer. Bootstrap open image in modal
How can I display images that's src comes from MySQL database?
simply echo
the img source from the database.
<?php
if(isset($_POST['profile_id'])){
var uid=$_POST['profile_id'];
$result->query("SELECT profile FROM user WHERE uid=$uid");
$row=$result->fetch_array();
die(json_encode($row));
}
?>
HTML:
<a href="#" class="pop">
<img src="" style="width: 400px; height: 264px;">
</a>
Jquery Part:
$.post("ajax.php",{profile_id:1},function(response){
if(response){
var profileImg=JSON.parse(response);
profileImg=profileImg[0].profile;
$('.pop img').attr('src','http://example.com/image/'+profileImg);
$('.pop').modal('show');
}
});