<?php
$pdo = new PDO('mysql:host=localhost;dbname=hospital;charset=utf8', 'admin01', 'admin01');
$pdo->query("set names utf8");
 
$title="一般內科";
$doctors = array (
    "w1"  => array("morning" => "", "afternoon" => "", "night" => ""),
    "w2"  => array("morning" => "", "afternoon" => "", "night" => ""),
	"w3"  => array("morning" => "", "afternoon" => "", "night" => ""),
    "w4"  => array("morning" => "", "afternoon" => "", "night" => ""),
	"w5"  => array("morning" => "", "afternoon" => "", "night" => ""),
    "w6"  => array("morning" => "", "afternoon" => "", "night" => ""),
	"w7"  => array("morning" => "", "afternoon" => "", "night" => "")
);
$depID = "31800";
if (isset($_GET["depID"]))
	$depID = $_GET["depID"];
 
$sql = "SELECT departName FROM `opd` WHERE departID='".$depID."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
$row = $pdoStatement->fetch();
$title=$row["departName"];
 
$sql = "SELECT dname, vsection, vday FROM schedule WHERE depID='".$depID."'";
$pdoStatement = $pdo->prepare($sql);
$ret = $pdoStatement->execute();
$rows = $pdoStatement->fetchAll();
 
foreach ($rows as $rowD)
{
	if ($rowD["vday"] == "星期一")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w1"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w1"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w1"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期二")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w2"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w2"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w2"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期三")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w3"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w3"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w3"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期四")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w4"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w4"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w4"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期五")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w5"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w5"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w5"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期六")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w6"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w6"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w6"]["night"] .=$rowD["dname"]."<br>";
	}
	else if ($rowD["vday"] == "星期日")
	{
		if ($rowD["vsection"] == "上午")
			$doctors["w7"]["morning"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "下午")
			$doctors["w7"]["afternoon"] .=$rowD["dname"]."<br>";
		else if ($rowD["vsection"] == "晚上")
			$doctors["w7"]["night"] .=$rowD["dname"]."<br>";
	}
}
?>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags:

This entry was posted on 星期三, 七月 8th, 2015 at 05:47:58 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