我有此代码,我想获取药物表
中的信息并将其显示在帐户表
中的acc_id
是 =
到药物表
中的acc_id
,其中med_timeoftheday='morning'
$postdata = file_get_contents("php://input");
if (isset($postdata)) {
$request = json_decode($postdata);
$User_ID = $request->acccid;
$sql = sprintf("SELECT * FROM account_info
join medication on account_info.acc_id = medication.acc_id
where account_info.acc_id='%s'",
mysqli_real_escape_string($conn,$User_ID));
$result=$conn->query($sql);
if ($result->num_rows>0)
{
while($row=$result->fetch_assoc())
{$data[]=$row;
}
echo json_encode($data);
}
}
这是我的ts:
我该怎么做?
提前谢谢您!
最佳答案
尝试这样的事情:
SELECT * FROM medication
INNER JOIN account_info ON account_info.acc_id = medication.acc_id
WHERE medication.med_timeoftheday='morning'
关于PHP select 不返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47758583/