PHP select 不返回值

标签 php mysql ionic2

我有此代码,我想获取药物表中的信息并将其显示在帐户表中的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/

相关文章:

mysql - 复选框未显示在 phpmyadmin 的新 UI 中

php - 安全的php模板引擎

php - 在 PHP 中使用 MySQL 数据进行搜索和排序

mysql - 在 MySQL 数据库中加密存储数百封电子邮件?

javascript - Ionic 2 - TypeScript | Ionic 2填充接口(interface)对象数组

sqlite - ionic 2 sqlite在android上运行:无法读取未定义的属性executeSql

node.js - cloud-Angular 没有导出成员 ProvideCloud

php - Eloquent fatal error : argument passed not the right instance

java - org.json.JSONException : Value <html><body>&lt;script of type java. lang.String 无法转换为 JSONObject

mysql - 我需要计算每个员工每月的平均产量