Daniel Kellaway
Daniel Kellaway

Reputation: 189

How to open images from MySQL within Bootstrap modal?

I have the following PHP function, instead of opening the image in a new page how do I open the image within a Bootstrap modal window?

public function getApartmentmedia($appmtid){
global $bsiCore; 
$medialist='';
$mediagalleryres=mysql_query("select img_path from bsi_appmt_gallery where appmt_id=".$appmtid);
if(mysql_num_rows($mediagalleryres)){
    while($row=mysql_fetch_assoc($mediagalleryres)){
            $medialist.='<a href="gallery/ApartImage/'.$row['img_path'].'"><img src="gallery/ApartImage/thumb_'.$row['img_path'].'" alt=""></a>';
    } 
}else{
    $medialist.='<h2>No Photos Found</h2>'; 
}
$medialist.='';
return $medialist;
}

Thanks

Upvotes: 0

Views: 288

Answers (1)

Matt
Matt

Reputation: 5428

Stick the image in a hidden div with a unique ID and then call: $('#modalId').modal('show'); when you want it to appear.

Upvotes: 2

Related Questions