I already did inner join before this code but then it seems like every time i have multiple queries it doesnt work. But then when I did it single query it seems fine and working. Please help me experts. Thank you!
<?php
include('db.php');
include('function.php');
if(isset($_POST["personal_info_id"]))
{
$id1 = $_POST["personal_info_id"];
$id2 = $_POST["personal_info_id"];
$sql = "SELECT * FROM hr_details WHERE personal_info_id = '$id1'";
$sql .="SELECT * FROM personal_info WHERE personal_info_id = '$id2'";
$output = array();
$statement = $connection->prepare($sql);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$output["firstname"] = $row["firstname"];
$output["middlename"] = $row["middlename"];
$output["lastname"] = $row["lastname"];
$output["address"] = $row["address"];
$output["birthdate"] = $row["birthdate"];
$output["gender"] = $row["gender"];
$output["religion"] = $row["religion"];
$output["civil_status"] = $row["civil_status"];
$output["biometrics"] = $row["biometrics"];
if($row["image"] != '')
{
$output['user_image'] = '<img src="upload/'.$row["image"].'" class="img-thumbnail" width="50" height="35" /><input type="hidden" name="hidden_user_image" value="'.$row["image"].'" />';
}
else
{
$output['user_image'] = '<input type="hidden" name="hidden_user_image" value="" />';
}
}
echo json_encode($output);
}
?>