<?php include 'includes/session.php'; ?>
<?php include 'includes/sessions.php'; ?>
<?php include 'includes/header.php'; ?>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <?php include 'includes/navbar.php'; ?>
  <?php include 'includes/menubar.php'; ?>

  <!-- Content Wrapper -->
  <div class="content-wrapper"> 
    <section class="content-header">
      <h1>All Photos</h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">User Monitoring</a></li>
        <li class="active">All Photos</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <?php
        // Get user_id from the URL
        $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : 0;

       
        // Check connection
        if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
        }

        // Fetch all photos for the user from the database (select only photo_path)
        $sql = "SELECT photo_path FROM user_photos WHERE user_id = ?";
        $stmt = $conn->prepare($sql);
        $stmt->bind_param('i', $user_id);
        $stmt->execute();
        $stmt->bind_result($photo_path);

        // Fetch and display photos
        $hasPhotos = false;
        while ($stmt->fetch()) {
          $hasPhotos = true;
          echo '
          <div class="col-md-3">
            <div class="thumbnail">
              <img src="https://xpydernetwork.com/user/user/' . $photo_path . '" alt="Photo" class="img-responsive">
            </div>
          </div>
          ';
        }

        if (!$hasPhotos) {
          echo '<p>No photos found for this user.</p>';
        }

        // Close the statement and connection
        $stmt->close();
        $conn->close();
        ?>
      </div>
    </section>
  </div>

  <?php include 'includes/footer.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
</body>
</html>
