<?php
require __DIR__ . '/../config/db.php';

$country = $_GET['country'] ?? 'USA';

$stmt = $pdo->prepare("SELECT stateAbbr, stateName FROM states_tbl WHERE country = ? AND active = 'y' ORDER BY stateName ASC");
$stmt->execute([$country]);
$states = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($states);