Initial Commit

This commit is contained in:
ldy
2025-06-06 17:31:03 +08:00
parent 787a7b5741
commit 66cd489ea8
244 changed files with 13574 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
// Include your database connection script
include '../connectDB.php';
// Get the state_id from the query string
$stateId = isset($_GET['state_id']) ? intval($_GET['state_id']) : 0;
// Array to hold cities
$cities = [];
// Fetch cities from the database based on state_id
if ($stateId > 0) {
$query = "SELECT `id`, `name` FROM cities WHERE state_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $stateId);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$cities[] = $row;
}
}
// Return the cities as JSON
header('Content-Type: application/json');
echo json_encode($cities);
?>