|
 |
|
สร้างระบบนัดคนไข้วันละ 3 คน ต่อแผนก มีโค๊ดดังนี้ ขอคำแนะนำบ้างนะครับ |
|
 |
|
|
 |
 |
|
1.ไฟล์ฟอร์มรับข้อมูลคนไข้จองผ่านเว็บ
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<center>
<h1>ข้อมูลการนัดตรวจ</h1>
<form action="testinsertto_appoint11.php" method="post">
<table>
<tr>
<td>เลขที่ผู้ป่วย(HN)</td>
<td><input name="HN" type="text" id="HN" maxlength="10"></td>
</tr>
<tr>
<td>แผนก(did): </td>
<td> <select name="depart" id="depart">
<option value="อายุรกรรม" selected>อายุรกรรม</option>
<option value="ศัลยกรรม">ศัลยกรรม</option>
<option value="สูติกรรม">สูติกรรม</option>
<option value="กุมารเวชกรรม">กุมารเวชกรรม</option>
<option value="ออโธปิดิกส์">ออโธปิดิกส์</option>
<option value="จักษุ">จักษุ</option>
<option value="หู คอ จมูก">หู คอ จมูก</option>
</select></td>
</tr>
<tr>
<td>วดปที่ต้องการนัด(01012553): </td>
<td><input name="date" type="text" id="date" size="8" maxlength="8">
</td>
</tr>
<tr>
<td>คนไข้เก่า/ใหม่</td>
<td><input name="oldnew" type="text" id="oldnew"></td>
</tr>
</table>
<input type="submit" value="submit">
</form>
</center>
</body>
</html>
2. ไฟล์ ตรวจสอบเงื่อนไข
<?php
$con = mysql_connect("localhost", "root", "") or
die("ไม่สามารถติดต่อ server ได้");
$db = mysql_select_db("appoint", $con) or
die("ไม่สามารถติดต่อกับฐานข้อมูลได้");
$date = $date ;
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");
$sql = "SELECT COUNT(*) FROM patient where depart = '$depart' and date = '$date' "; //นับจำนวนวันเพื่อใช้กำหนด
$result = mysql_query($sql);
$patient = mysql_result($result, 0);
$sql3 = "SELECT COUNT(*) FROM patient where HN = '$HN' and date = '$date' ";
$result3=mysql_query($sql3);
$dup = mysql_result($result3,0);
if($dup <> 0){
print "<a href=appoint_forminserttest.php>ชื่อนี้ได้นัดตรวจแล้ว</a>";
}else if($patient >= 3){
print "<a href=appoint_forminserttest.php>กรุณาเปลี่ยนวัน</a>";
}else if ($patient < 3){
echo "เลขที่บัตรผู้ป่วย:".$_POST["HN"] ."<br>" ;
echo "แผนก:".$_POST["depart"] ."<br>" ;
echo "วันที่นัดตรวจ:".$_POST["date"] ."<br>" ;
echo "ผู้ป่วยเก่า/ใหม่:".$_POST["oldnew"] ."<br>" ;
echo "<script type=\"text/javascript\">";
echo "if( confirm(\"ยืนยันการนัดตรวจ\") == true) { window.location.hash = '#78'}else{window.location.hash = '78'}";
echo "</script>";
$sql2 = "insert into patient " .
"(HN,depart,date,oldnew)" .
" values " .
"('" .
$_POST["HN"] . "','" .
$_POST["depart"] . "','" .
$_POST["date"] ."','" .
$_POST["oldnew"] .
"')";
mysql_query($sql2, $con) or
die("ไม่สามารถทำงานตามคำสั่ง SQL ได้");
print " รพ.ได้รับการนัดของคุณแล้ว";
mysql_close($con);
}
?>
แนะนำบ้างก็ได้นะครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript

|
|
 |
 |
 |
 |
Date :
2010-11-29 13:54:25 |
By :
pechps |
View :
2444 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เมล์มาคุยกันนะครับ เดียวผมจะ อธิบายให้ฟังนะครับผม
จะได้เข้าใจนะครับ หรือจะโทรมาก็ได้นะครับ 088-488-4841
|
 |
 |
 |
 |
Date :
2010-12-02 11:28:23 |
By :
บ้านโปรแกรมเมอร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|