如何将这两个查询组合成一个php数组,以json格式回显ajax请求?每一个声明都被确认是单独工作的。
看起来像:
'fname' => $fname,
'lname' => $lname,
'gender' => $gender,
'city' => $city,
'state' => $state
'bio' => $bio
PHP MySQL请求
<?php
include 'sqlconnection.php';
$conn = OpenCon();
$stmt = $conn->prepare('SELECT fname,lname,gender,city,state FROM users WHERE uid='.$_POST['info']);
$stmt->execute();
$stmt->bind_result($fname,$lname,$gender,$city,$state);
while($stmt->fetch()) {
$output=array(
'fname' => $fname,
'lname' => $lname,
'gender' => $gender,
'city' => $city,
'state' => $state
);
}
$json=json_encode($output);
echo $json;
$stmt = $conn->prepare('SELECT bio FROM profile WHERE uid='.$_POST['info']);
$stmt->execute();
$stmt->bind_result($bio);
while($stmt->fetch()) {
$output=array(
'bio' => $bio
);
}
$json=json_encode($output);
echo $json;
$stmt->close();
CloseCon($conn);
?>