小弟的毕业设计是用PHP+MYSQL做门诊收费管理系统,相当无语的是现在挂号功能和医生开处方功能都实现了,但是不能收费。汗一个~~~我对PHP和SQL语句不是很熟悉,在此向大家求助啊~~
  现在是有处方表chufang,里面有字段药品名tools1,数量quantity1,药品名tools2,数量quantity2,检查项目info.  
  1.需要检索药品表medicine中的字段price,处方表和药品表中药品名是对应的。 
  2.需要检索收费项目表info中的字段price,收费项目表name和处方表中info字段对应。
  3.收费金额total=(tools1)price×quantity1+(tools2)price×quantity2+(info)price
   最后,将处方表ID和total输出。
   由于白天实习只有晚上有时间做,最后这个问题已经困扰了整整我5天了,唉~~~
   
  我写了一段程序,貌似有问题,给大家看看。
<body>
<p align="center" class="STYLE1">收费系统</p><hr align="center">
<form action="shoufei_final.php" method="POST">
<div align="center">
  <table width="528" border="1" cellpadding="1" cellspacing="0">
  <tr>
    <?php require("conn.php");
$id = $_GET["id"];
$sql = "select t1.price as price1,t2.price as price2,chufang.quantity1,chufang.quantity2,info.price from chufang left join medicine as t1 on chufang.tools1=medicine.name
left join medicine as t2 on chufang.tools2=medicine.name
left join info as info on chufang.info=info.name where chufang.id='$id' ";$re = mysql_query($sql);
echo mysql_error();
while($rs=mysql_fetch_array($re)){
      echo "<td width=\"50\">$rs[price1]</td>";

/*此处我不明白,我希望输出药品名chufang.tools1,药品数量chufang.quantity1和药品价格medicine.price,检查费用名info.name和价格info.price,最后再有个总金额。但是我不知道怎么弄。另外,mysql_error()提示t2.price参数不存在。*/
?>
  </tr>
</table>
  <p>
    <input type="submit" value="打印" onClick="javascript:window.print()"/>&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" name="Submit2" value="不行,我要返回修改" />
</p>
</div>
</form>
</body>   我对多表查询不太明白,这个SQL语句可能不太对,还有输出部分我也不会,向大家求助啊~~~

解决方案 »

  1.   

    /*此处我不明白,我希望输出药品名chufang.tools1,药品数量chufang.quantity1和药品价格 medicine.price,检查费用名info.name和价格info.price,最后再有个总金额。但是我不知道怎么弄。另外,mysql_error()提示t2.price参数不存在。*/你在select 后面没有 chufang.tools1 这个字段 ,查询结果里就不会有药品名。关于 mysql_error()提示t2.price参数不存在 请仔细medicine表中是否有price这个字段,或是否有拼写错误。