<?php
header('Content-Type: text/html; charset=utf-8');

show_source(__FILE__); // <- IMPORTANT REMOVE THIS LINE/CODE or everybody can see your code!!!

include ('DBcon.php');
// in DBcon.php:
// $db_hostname = "**************";
// $db_database = "**************";
// $db_username = "**************";
// $db_password = "**************";

    $mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
        
    if (mysqli_connect_errno())
    {
        echo 'error';
        exit();
    }

    $status = 'active';
    $temp   = 'deleted'; // Just to show deleted items

    $mysqli->set_charset("utf8mb4");    

    $stmt = $mysqli->prepare("SELECT gamerID as gamerID, name as name, birthdate as birthdate, status as status
        FROM gamers
        WHERE status = ? OR status = ?");
    $stmt->bind_param("ss", $status, $temp);
    $stmt->execute();
    $result = $stmt->get_result();
    if($result->num_rows === 0) exit('norecords');
    while($row = $result->fetch_assoc()) {
        
         $gamers[] = array(
          'gamerID'   => $row['gamerID'],
          'name'      => $row['name'],
          'birthdate' => $row['birthdate'],
          'status'    => $row['status']
         );
    }
    echo json_encode($gamers);
    $stmt->close();
?>
[{"gamerID":1087,"name":"Gracie Rios","birthdate":"1969-02-23","status":"active"},{"gamerID":1074,"name":"Jenny Smith","birthdate":"1980-02-12","status":"active"},{"gamerID":1075,"name":"Reynard Ogley","birthdate":"2025-02-14","status":"active"},{"gamerID":1089,"name":"Aniya Patton","birthdate":"1972-02-23","status":"active"},{"gamerID":1088,"name":"Bexley Blackwell","birthdate":"1978-02-23","status":"active"},{"gamerID":1078,"name":"Talia Vargas","birthdate":"1989-02-12","status":"active"},{"gamerID":1079,"name":"Wade Cantrell","birthdate":"1990-02-12","status":"active"},{"gamerID":1086,"name":"Georgia Good","birthdate":"1991-02-23","status":"active"},{"gamerID":1082,"name":"Oriel Guzman","birthdate":"1999-02-12","status":"active"},{"gamerID":1083,"name":"Ralph Steele","birthdate":"2002-02-12","status":"active"},{"gamerID":1084,"name":"Frank Quinn","birthdate":"2010-02-12","status":"active"},{"gamerID":1085,"name":"Michael Tate","birthdate":"2011-02-12","status":"active"},{"gamerID":1090,"name":"Raquel Jimenez","birthdate":"2012-02-23","status":"active"},{"gamerID":1091,"name":"Deborah Paul","birthdate":"2001-02-23","status":"active"},{"gamerID":1092,"name":"Moises Randall","birthdate":"2005-02-23","status":"active"}]