File "load_behavioral_indicators.php"

Full Path: /home/humancap/cl.humancap.com.my/assessment/cl-admin/monitor/load_behavioral_indicators.php
File size: 1.01 KB
MIME-type: text/x-php
Charset: utf-8

<?php
require_once "../include/config.php";

// Create a database connection
$conn = new mysqli($host, $username, $password, $database);

// Check the connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch behavioral indicators based on selected competency
if(isset($_POST['competency'])) {
    $selectedCompetency = $_POST['competency'];
    
    // Simulated behavioral indicators data
    // GET BIs DATA
    $sql = "SELECT bi.id, bi.name as mybi, c.name as competency, c.nama as kompetensi FROM behavioral_indicator as bi 
             INNER JOIN competency as c ON bi.competency_id = c.id where c.id =" .$selectedCompetency ;
    $result = $conn->query($sql);

    $behavioralIndicators = array(); // Array to store behavioral indicators

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            $behavioralIndicators[] = $row['mybi'];
        }
    }
    //var_dump($behavioralIndicators);
    echo json_encode($behavioralIndicators);
}
?>