<?php
require '../../includes/session-check.php';
// Create a new PDO instance
$pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);

// Get the selected option value
$selectedOption = $_GET['selectedOption'];

// Retrieve the corresponding data from the database
$stmt = $pdo->prepare("SELECT p_sale_px, p_prch_px, sale_comm,margin, sku, 	prch_comm, admin_fee, sale_vat, inp_vat FROM products WHERE id = ?");
$stmt->execute([$selectedOption]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);

// Prepare the response as an associative array
$response = [
  //'column2' => $result['p_prch_px'],
  'column3' => $result['p_sale_px'],
  'column4' => $result['p_prch_px'],
  'column5' => $result['sale_comm'],
  'column6' => $result['margin'],
  'column7' => $result['sku'],
  'column8' => $result['prch_comm'],
  'column9' => $result['admin_fee'],
  'column10' => $result['sale_vat'],
  'column11' => $result['inp_vat'],
  
  
];

// Output the response as JSON
echo json_encode($response);
?>
