whoami7 - Manager
:
/
home
/
gracious
/
hris.graciousphils.com
/
backup hris employee
/
Upload File:
files >> /home/gracious/hris.graciousphils.com/backup hris employee/fetch_data.php
<?php session_start(); $host = "localhost"; $port = 3306; $socket = ""; $user = "gracious_administrator"; $password = "Cronica2020"; $dbname = "gracious_hris"; try { // Create a PDO connection $dbh = new PDO("mysql:host={$host};port={$port};dbname={$dbname}", $user, $password); // Set the PDO error mode to exception $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Get the selected subcategory name from the AJAX request $subcategoryName = $_POST['column']; // Assuming EmpId is an integer, you can use intval to sanitize the input $empId = intval($_SESSION['empid']); // Fetch the data for the selected subcategory and EmpId from your database $stmt = $dbh->prepare("SELECT $subcategoryName FROM tblemployees WHERE EmpId = :emps"); $stmt->bindParam(':emps', $empId, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result) { // Output the data echo $result[$subcategoryName]; } else { echo "No data found"; } } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
Copyright ©2021 || Defacer Indonesia