0
我的PHP查询有问题。我只需要在列表视图中获取点击患者的处方。如何查询外键并获取相应的行
这里是处方的表格结构。
我需要患者ID 79,以显示他的所有相应的处方。请帮帮我。
这里是PHP。
<?php
/*
* Following code will list all the products
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
if (isset($_GET["uid"])) {
$uid = $_GET['uid'];
// get all products from products table
$result = mysql_query("select * from prescription") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["prescription"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$prescription = array();
$prescription["pres_id"] = $row["pres_id"];
$prescription["pres_name"] = $row["pres_name"];
//$product["price"] = $row["price"];
// push single product into final response array
array_push($response["prescription"], $prescription);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No prescriptions found";
// echo no users JSON
echo json_encode($response);
}
}else {
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
}
?>
SELECT * FROM处方内加入patient.patient_id哪里prescription.patient_id ='79'? – user2002495
好吧,您还需要在处方表中有patient_id字段以及 – user2002495