Opening image by clicking HTML + PHP + JS

0

I'm looking for the images in the database and is listing everything correct, fixed size and etc ... I wanted when I clicked on it open it larger, on the same page, as a modal and with the bigger photo ...

<?php
include('config.php');
$result = mysql_query("SELECT * FROM photos");
while($row = mysql_fetch_array($result))
{
echo '<div id="imagelist">';
echo '<p><img src="'.$row['location'].'></p>';
echo '<p id="caption">'.$row['caption'].' </p>';
echo '</div>';
}   
?>
<?php
include('config.php');
$result = mysql_query("SELECT * FROM photos");
while($row = mysql_fetch_array($result))
{
echo '<div id="imagelist" onClick="openimg()">';
echo '<p><img src="'.$row['location'].'"></p>';
echo '<p id="caption">'.$row['caption'].' </p>';
echo '</div>';
}   
?>

<script type="text/javascript">
    function openimg() {
    $('#blankImage').show();
    return false;
    }
 </script>
    
asked by anonymous 06.02.2017 / 14:43

1 answer

0

In this case, I recommend using Magnific Popup. link That is a lightbox of images, it also works well with galleries.

Its implementation is simple: link

    
09.02.2017 / 12:29