<?php
if (empty($_GET["sid"]) || empty($_GET["rid"])) 
{
   $redir = "/";
   header("Location: $redir");
   exit;
}
$sid = $_GET["sid"];
$rid = $_GET["rid"];
 
$pdo = new PDO('mysql:host=localhost;dbname=hospital;charset=utf8', 'admin01', 'admin01');
$pdo->query("set names utf8");
 
//取得預約的醫師及日期時段
$sql = "SELECT depID, dname, vsection, vday FROM schedule WHERE id ='".$sid."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
$schedule = $pdoStatement->fetch(); 
$depID = $schedule["depID"];
$dname = $schedule["dname"];
$vsection = $schedule["vsection"];
$vday = $schedule["vday"];
 
//把預約人數先加一
$sql = "UPDATE reservation SET count=count+1 WHERE id ='".$rid."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
 
//取得預約日期
$sql = "SELECT visit_date FROM `reservation` WHERE id ='".$sid."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
$reserve = $pdoStatement->fetch(); 
$vdate = $reserve["visit_date"];
 
//取得預約科別
$sql = "SELECT departName FROM opd WHERE departID ='".$depID."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
$row = $pdoStatement->fetch();
$departName="小小科";
if (!empty($row["departName"]))//$row["departName"]=$row[0]
   $departName=$row["departName"];
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文件</title>
</head>
 
<body>
<h2>亞大(模擬)醫院預約門診</h2>
<hr />
<form name="reg_form" id="reg_form" action="opd-serve-query.php" method="POST">
<table border="2" cellpadding="1" align="center" width="600">
   <tr>
    <td>科別:<?php echo $departName?> /醫生:<?php echo $dname?></td><td>日期:<?php echo $vdate?>(<?php echo $vday?>)/時段:<?php echo $vsection?></td>
    </tr>
<tr>
    <td>病人身份證號碼:<input type="text" name="PatientID" id="PatientID" /></td>
    <td>病人姓名:<input type="text" name="PatientName" id="PatientName"/></td>
</tr>
<tr>
    <td colspan="2" align="right"><input type="button" name="SubmitNew" id="SubmitNew" value="預約" /></td>
</tr>
</table>
</form>
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: ,

This entry was posted on 星期一, 七月 13th, 2015 at 07:27:06 and is filed under 104(暑)程式設計營. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment