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

File Manager

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

Melihat File: contestants3.php

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

// Define current stage safely
$current_stage = isset($current_stage) ? intval($current_stage) : 0;

// Pagination setup
$results_per_page = 15;

// Get total number of results (safe query)
$sql_count = "SELECT COUNT(*) AS total FROM registration";
$count_result = mysqli_query($conn, $sql_count);
$row = mysqli_fetch_assoc($count_result);
$number_of_results = intval($row['total']);
$number_of_pages = ceil($number_of_results / $results_per_page);

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

// Calculate start record
$page_first_result = ($page - 1) * $results_per_page;

// Fetch records with limit (safe query)
$stmt = $conn->prepare("SELECT Id, Childsname, Image, stage_three_vote, vote FROM registration ORDER BY id ASC LIMIT ?, ?");
$stmt->bind_param("ii", $page_first_result, $results_per_page);
$stmt->execute();
$result = $stmt->get_result();
$contestants = $result->fetch_all(MYSQLI_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contestants</title>

<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-16759433870"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-16759433870');
  gtag('config', 'G-DWZP5NWRWX');
</script>

<?php include('nav.php'); ?>

<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>
</head>

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

<section class="center" style="margin-top: 6rem;">
  <a href="search3.php" style="color:#FCB900; font-weight: bold; text-align: center;">Search Contestants</a>
</section>

<main class="container">
  <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 center hoverable" style="padding-bottom: 40px; border-radius: 15px;">
          <br>
          <img src="<?= htmlspecialchars($cons['Image']) ?>" class="avatar"
               style="object-fit: cover; border-radius: 20px; width: 200px; height:230px;" alt="">
          <h6 class="center" style="margin: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #000000a4; font-weight: bold;">
            <?= htmlspecialchars($cons['Childsname']) ?>
          </h6>

          <div style="font-weight: bold; color: #FCB900; font-size: 1.4rem;">
            <?= intval($cons['stage_three_vote']) ?> Votes
          </div>

          <?php
          // Stage logic
          $id = intval($cons['Id']);
          $voteForm = '';
          switch ($current_stage) {
              case 0:
                  $voteForm = "notyet.php?id=$id";
                  break;
              case 1:
                  $voteForm = "voter1.php?id=$id";
                  break;
              case 2:
                  $voteForm = "voter2.php?id=$id";
                  break;
              case 3:
                  $voteForm = "voter3.php?id=$id";
                  break;
              default:
                  $voteForm = "notyet.php";
          }
          ?>
          <form action="<?= $voteForm ?>" method="POST">
            <input type="hidden" name="id" value="<?= $id ?>">
            <input type="submit" name="vote" class="btn btno z-depth-0" value="Vote">
          </form>
        </div>
      </div>
    <?php endforeach; ?>

    </div>
  </section>

  <div class="center">
    <?php if ($page > 1): ?>
      <a href="contestants3.php?page=<?= $page - 1 ?>" class="btn z-depth-4" style="background-color: #FCB900">Previous Page</a>
    <?php endif; ?>

    <?php if ($page < $number_of_pages): ?>
      <a href="contestants3.php?page=<?= $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    ÿþ$ ÿÂ