35263-vm/api.php
Flatlogic Bot 18b6dbc27d V1
2025-10-26 23:03:53 +00:00

16 lines
574 B
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *'); // Allow all origins for now
require_once 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->query('SELECT id, title, location, description, company, salary_range, created_at FROM jobs ORDER BY created_at DESC');
$jobs = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['success' => true, 'data' => $jobs]);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
}
?>