<?php
include 'db.php';
session_start();
echo "<h3>Public Images</h3>";
$public = mysqli_query($conn, "SELECT * FROM image WHERE access_type='public'");
while ($row = mysqli_fetch_assoc($public)) {
    echo "<div><img src='uploads/{$row['filename']}' width='150'><br>{$row['comment']}<br></div>";
}
if (isset($_SESSION['user'])) {
    echo "<h3>Your Private Images</h3>";
    $email = $_SESSION['email'];
    $private = mysqli_query($conn, "SELECT * FROM image WHERE access_type='private' AND user_email='$email'");
    while ($row = mysqli_fetch_assoc($private)) {
        echo "<div><img src='uploads/{$row['filename']}' width='150'><br>{$row['comment']}<br><a href='delete.php?id={$row['id']}'>Delete</a></div>";
    }
}
?>