ÿØÿà JFIFÿØÿà JFIF ÿØÿà JFIFÿØÿà JFIF   ÿþ$    File Manager

File Manager

Path: /home/u371470492/domains/babiesnitch.com/public_html/

Melihat File: contestants1.php

<?php 
session_start();
include('config.php');

// Define current stage safely
$current_stage = isset($_SESSION['current_stage']) ? $_SESSION['current_stage'] : 0;
$cas = session_id(); // fallback unique session ID
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Contestants</title>

  <!-- Correct Materialize CSS/JS -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

  <style>
    .btno {
      background-color: #560280;
      color: white;
      border-radius: 10px;
    }
    .btno:hover {
      color: #560280;
      background-color: white;
      text-decoration: none;
      font-weight: bold;
      border: solid 1px #FCB900;
      border-radius: 10px;
    }
  </style>
 <?php include('nav.php'); ?>
</head>

<body>
    
  <br><br><br><br>

  <section class="center">
    <a href="search1.php" style="color:#FCB900; font-weight: bold;">Search Contestants</a>
  </section>

  <main class="container">

    <?php 
      // ✅ Pagination setup
      $results_per_page = 15;

      // Count total contestants
      $count_query = "SELECT COUNT(*) AS total FROM registration";
      $count_result = mysqli_query($conn, $count_query);
      $row = mysqli_fetch_assoc($count_result);
      $number_of_results = $row['total'];
      $number_of_pages = ceil($number_of_results / $results_per_page);

      // Current page
      $page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
      if ($page < 1) $page = 1;
      if ($page > $number_of_pages) $page = $number_of_pages;

      $page_first_result = ($page - 1) * $results_per_page;

      // Fetch contestants for current page
      $query = "SELECT * FROM registration ORDER BY id ASC LIMIT $page_first_result, $results_per_page";  
      $result = mysqli_query($conn, $query);
      $contestants = mysqli_fetch_all($result, MYSQLI_ASSOC);
    ?>

    <section>
      <div class="row">
        <br>
        <?php foreach ($contestants as $cons) { ?>
          <div class="col l3 m6 s12 center" style="font-family: Trebuchet MS;">
            <div class="card z-depth-1 hoverable" style="padding-bottom: 40px; border-radius: 15px;">
              <br>
              <img src="<?php echo htmlspecialchars($cons['Image']); ?>" 
                   alt="Contestant Image" 
                   style="object-fit:cover; border-radius: 20px; width: 200px; height:230px;">

              <h6 class="center" style="margin: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #000000a4; font-weight: bold;">
                <?php echo htmlspecialchars($cons['Childsname']); ?>
              </h6>

              <div style="font-weight: bold; color: #FCB900; font-size: 1.4rem;">
                <?php echo (int)$cons['vote']; ?> Votes
              </div>
          <?php
          echo $current_stage;
                // ✅ Determine which voting page to use
                switch ($current_stage) {
                  case 0:
                    $action = "notyet.php";
                    break;
                  case 1:
                    $action = "voter1.php";
                    break;
                  case 2:
                    $action = "voter2.php";
                    break;
                  case 3:
                    $action = "voter3.php";
                    break;
                  default:
                    $action = "notyet.php";
                }
              ?>


              
              <form action="<?php echo $action; ?>?id=<?php echo $cons['Id']; ?>" method="POST">
                <input type="hidden" name="id" value="<?php echo $cas; ?>">
                <input type="submit" name="vote" class="btn btno z-depth-0" value="Vote">
              </form>
            </div>
          </div>
        <?php } ?>
      </div>
    </section>

    <!-- Pagination Controls -->
    <div class="center" style="margin-top: 2rem;">
      <?php if ($page > 1): ?>
        <a href="contestants1.php?page=<?php echo $page - 1; ?>" class="btn z-depth-4" style="background-color: #FCB900;">Previous Page</a>
      <?php endif; ?>

      <?php if ($page < $number_of_pages): ?>
        <a href="contestants1.php?page=<?php echo $page + 1; ?>" class="btn" style="background-color: #FCB900;">Next Page</a>
      <?php else: ?>
        <label style="font-size: 1.4rem;">Last Page</label>
      <?php endif; ?>
    </div>

  </main>

  <br>
  <?php include('footer.php'); ?>
</body>
</html>
ÿØÿà JFIF    ÿþ$ ÿØÿà JFIF    ÿþ$ ÿÂ