File "fetch_applicants.php"

Full path: /home/fsibplc/public_html/fsib/accountOpening-v2/fetch_applicants.php
File size: 872 B (872 B bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php
header('Content-Type: application/json');

// Database configuration
$host = 'localhost'; // Your database host
$dbname = 'fsibplc_account_opening'; // Your database name
$username = 'root'; // Your database username
$password = ''; // Your database password

try {
    // Create a new PDO instance
    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // Prepare and execute the query
    $stmt = $pdo->prepare("SELECT * FROM `account_info` WHERE `status` IS NULL ORDER BY `id` ASC;");
    $stmt->execute();

    // Fetch all applicants
    $applicants = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Return the data as JSON
    echo json_encode($applicants);
} catch (PDOException $e) {
    echo json_encode(['error' => $e->getMessage()]);
}
?>