Dear all,
Help required in code: I have 2 tables (sites and photo_gallery) in my database. First I display my posts from database, then it goes to my viewpost page.
Everything work file but in gallery portion my loop didn't work.
IN TOP of the page I use this code to run all viewpost pages.
if(isset($_GET['id'])) {
require_once("_includes/LocalHost.php");
$id = mysqli_real_escape_string($db, $_GET['id']);
$sql = "SELECT * FROM sites, photo_gallery WHERE gallery_con = photo_id AND id='$id' ";
$result= mysqli_query($db, $sql) or die("Bad Query: $sql");
$row = mysqli_fetch_array($result);
}
In gallery portion
<?php
if($result->num_rows > 0){
while($row = $result->fetch_assoc()) {
$title = $row["title_post"];
$imageURL = 'images/'.$row["photographs"];
$imageThumbURL = 'images/thumb_'.$row["photographs"];
?>
<a href="<?php echo $imageURL; ?>" class="image" data-fancybox="images">
<img src="<?php echo $imageThumbURL; ?>" alt="<?php echo $title; ?>" height="200px" />
</a>
<?php }
}
?>
1 to 15 images with every post and it will display only one 2nd image.
Thank you for the help.