I have 2 dynamic dependent SelectBoxes one with Client Name and the other with Invoice Date with a button to fetch data according to the client name and his date respectively and populate the form fields below. This whole process is completed and was working but due to the date is not fetching the whole process stops. Now client is up to my arse and I don't know what to do. I am not very good with php or js. If you guys can help me with this and try to explain in more easy way I will be in your debt. TIA.
It was working fine but suddenly its fetching client name but not the dates i don't know why. The program was working fine for almost 5 6 months but few days ago this error occurs out of nowhere without any changes.
I tried to creating new Database thinking may be it was the error but it didn't work.
I also restored the code file with the backup but still no luck.
//data.php
<?php
require '../db_connection.php';
header("Access-Control-Allow-Origin: *");
$action = $_GET['action'];
if($action=="getclientRecords"){
getclientRecords($con);
}
function getclientRecords($con){
$id = $_POST['client_id'];
$sql="SELECT `invoice_data`.`item_date` FROM `invoice_data` WHERE `invoice_data`.`client_id`=$id";
$result = mysqli_query($con, $sql);
$results = mysqli_fetch_all($result);
return json_encode($results);
}
$date = $_GET['action'];
if($date=="getclientRecordByDate"){
getclientRecordByDate($con);
}
function getclientRecordByDate($con){
$client_date = $_POST["date"];
$client_id = $_POST["client_id"];
$sql = "SELECT client_name, `item_date`, item_refe, item_parti, balance_amount, item_amnd, item_amnf, item_tax, item_amniw, item_amnif FROM `invoice_data` WHERE `item_date` = '$client_date' AND client_id = '$client_id'";
$result = mysqli_query($con, $sql);
$results = mysqli_fetch_array($result);
echo json_encode($results);
}
?>
Result. I.E.
Client name = YAP KHIN CHOY
Date: 2 June, 2019, 3 June, 2019, 5 June, 2019
Pressing Fetch Button:
Populate the form below with the relevant data.