我将A. SKU_CODE存储到医生详细信息表中,因为它以逗号为基础,现在正在从数据库中检索数据,现在案例是将值变为null,我需要以逗号为基础显示数据字符串。
这是将数据插入数据库的正确方法还是以任何其他更好的方式插入数据。
<?php
include('config.php');
if($_SERVER['REQUEST_METHOD'] == "POST"){
$employee_id=$_POST['EMPLOYEE_ID'];
$sel="SELECT A.DRSYSCODE,A.DOCTOR_NAME,A.CONVERTED,C.POB_PRODUCT
FROM DOCTORDETAILS A
LEFT JOIN POB C ON A.SKU_CODE=C.POB_CODE
WHERE CREATEDBY=$employee_id";
$qry=mysql_query($sel);
while($row=mysql_fetch_assoc($qry))
{
$select="SELECT D.CREATEDON,B.POB_NAME,B.POBQTY,SUM(D.SOLDQTY)
FROM DOCTORDETAILS A
LEFT JOIN U_POB B ON A.DRSYSCODE=B.SYSCODE
LEFT JOIN POBSOLD D ON A.DRSYSCODE=D.SYSCODE
WHERE B.POBQTY>0 AND A.DRSYSCODE='".$row['DRSYSCODE']."'";
$query=mysql_query($select);
$doctordetails=array();
$doctordata=array();
while($quantity=mysql_fetch_array($query)){
$doctordetails[]=array("POB_NAME"=>$quantity['POB_NAME'],"POBQTY"=>$quantity['POBQTY'],
"SOLDQTY"=>$quantity['SOLDQTY'],
"CREATEDON"=>$quantity['CREATEDON']);
}
$doctordata[]=array("DOCTOR_NAME"=>$row['DOCTOR_NAME'],
"CONVERTED"=>$row['CONVERTED'],"POB_PRODUCT"=>$row['POB_PRODUCT'],
"POB"=>array($doctordetails));
}
if($doctordata){
$json = array("status" => 1,
"data"=> $doctordata,
"msg" => "Data retrived Successfully");
}
else{
$json = array("status" => 2,
"msg" => "Data cannot be retrived");
}
}
else{
$json = array("status" => 0,
"msg" => "Request method not accepted");
}
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
?>
POB_PRODUCT存储在数据库中
POBDA001,POBDA002,POBDA003,POBDA004,POBDA005,POBDA006,POBDA007,
获得的输出响应:
{
"status": 1,
"data": [
{
"DOCTOR_NAME": "TESTING",
"CONVERTED": "YES",
"POB_PRODUCT": null,
"POB": [
[
{
"POB_NAME": "TASTE GOOD",
"POBQTY": "20",
"SOLDQTY": null,
"CREATEDON": null
}
]
]
}
],
"msg": "Data retrived Successfully"
}
必填项:
{
"status": 1,
"data": [
{
"DOCTOR_NAME": "CHIRANJEEVI",
"CONVERTED": "YES",
"POB_PRODUCT": "PROUCT1,PRODUCT2,PRODUCT3",
"POB": [
[
{
"POB_NAME": "TASTE GOOD",
"POBQTY": "20",
"SOLDQTY": null,
"CREATEDON": null
}
]
]
}
],
"msg": "Data retrived Successfully"
}