( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
// Database connection details
$host = 'localhost';
$dbname = 'thebrand';
$username = 'root';
$password = 'Pw4TheBrand!';
try {
// Connect to the database
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$brand = $_GET['brand'];
// Query to fetch font families
$stmt = $pdo->query("SELECT file as family FROM myfonts where catalogid=$brand and isdisplay=1");
// Fetch all results as an associative array
$fonts = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Prepare the JSON structure
$data = ["items" => $fonts];
// Convert to JSON
$json = json_encode($data, JSON_PRETTY_PRINT);
// Output the JSON
header('Content-Type: application/json');
echo $json;
} catch (PDOException $e) {
// Handle connection errors
echo "Database error: " . $e->getMessage();
}
?>