<?php include('includes/config/config.php'); include('log_entry.php'); $itemId = $_REQUEST['item_id']; $query = "select a.*,b.cat_name,c.form_name,d.unit_name,m.medicine_usage_cat_name from tbl_items a left join tbl_categories b on b.cat_id=a.cat left join medicine_form c on c.form_id=a.item_form_id left join unit_master d on d.unit_id=a.unit_id left join medicine_usage_cat m on m.medicine_usage_cat_id = a.medicine_usage_cat_id where a.item_id = '" . $itemId . "'"; error_log("query to get item " . $query); if (!$result = @mysqli_query($conn, $query)) { die(mysqli_error($conn)); } $data = array(); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $data = $row; } } else { $data['status'] = 200; $data['message'] = "Data not found!"; $data['sql'] = $query; } $query_salt = "select salt_id from item_salt where item_id='" . $itemId . "' "; error_log($query_salt); $salt_name = array(); if (!$result_salt = @mysqli_query($conn, $query_salt)) { die(mysqli_error($conn)); } if (mysqli_num_rows($result_salt) > 0) { while ($row_salt = mysqli_fetch_assoc($result_salt)) { array_push($salt_name, $row_salt['salt_id']); } } $data['salt'] = $salt_name; error_log('data :' . print_r($data, true)); echo json_encode($data);