|
|
|
ช่วยดูให้หน่อยค่ะ ปัญหาเรื่องการตั้งเงื่อนไข if ค่ะ เลือกแล้วข้อมูลไปแสดงเงื่อนไขสุดท้ายเลยค่ะไม่แสดงเงื่อนไขก่อนหน้า |
|
|
|
|
|
|
|
นี่คือโค๊ดที่ใช้นะคะ รบกวนช่วยดูให้หน่อยนะคะ หาไม่เจอจริงๆ ไม่แน่ใจด้วยว่าเรียงลำดับ if ถูกต้องหรือเปล่า
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<title>headFindDoctor</title>
</head>
<body>
<br>
<?
//$db_host="localhost";
$db_user="";
$db_pass="";
$db_name="mydatabase";
//$db_connstr="Driver={Microsoft Access Driver (*.mdb)};";
//$db_connstr.="DBQ=".realpath($db_name.".mdb").";"; //ãªéä´é
$conn=odbc_connect($db_name,$db_user,$db_pass);
if($conn)
{
echo "";
}
else
{
echo "Not Connect";
}
$sql="SELECT DISTINCT Specialty FROM M_CUSTOMER_CONTACT";
$sql_statement = odbc_exec($conn,$sql) or die("Not exec Statement");
?>
<form name="findDoctor" method="post" target="_self" action="FindSpecialty.php">
<table align="center" border="1">
<tr><td align="right">Specialty :</td>
<td align="left"><?
echo "<select name='Combo_Specialty' width='100' height='18'>";
echo "<option value=''></option>";
while ($objResult=odbc_fetch_array($sql_statement)){
$Specialty = $objResult['Specialty'];
echo "<option value=$Specialty>".$Specialty."</option>";
}
echo "</select>";
?></td>
<td rowspan="2"><input type="submit" width="100" height="100" value="FIND" name="Find"/></td>
</tr>
<tr><td align="right">Hospital Type : </td>
<td align="left"><?
$sql1="SELECT * FROM P_HOSPITAL_TYPE";
$sql_statement1 = odbc_exec($conn,$sql1) or die("Not execute Statement");
echo "<select name='Combo_Hospital_type' width='100' height='18'>";
echo "<option value=''></option>";
while ($objResult=odbc_fetch_array($sql_statement1)){
$Hospital_type = $objResult['Hospital_type'];
echo "<option value=$Hospital_type>".$Hospital_type."</option>";
}
echo "</select>"; ?></td>
</tr>
<tr><td align="right">BKK/UPC : </td>
<td align="left"><?
$sql="SELECT * FROM P_PROVINCE";
$sql_statement = odbc_exec($conn,$sql) or die("Not execute Statement");
echo "<select name='Combo_P_Province' width='100' height='18'>";
echo "<option value='0'></option>";
echo "<option value='1'>BKK</option>";
echo "<option value='2'>UPC</option>";
echo "</select>"; ?></td>
</tr>
</table>
</form>
<br/></dl></dl>
<table width="100%" border="1" align="center">
<tr bgcolor="#CC0000">
<td size="25" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="80" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="80" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="50" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="200" height="22"><font color="white"> <div align="center"></div></font></td>
</tr>
<?
if(isset($Find))
{
if(($Combo_Specialty==NULL)&&($Combo_Hospital_type==NULL)&&($Combo_P_Province==NULL))
{
echo"<script language=\"JavaScript\">";
echo"alert('Please Select Criteria and Province')";
echo"</script>";
}
else if(($Combo_Specialty!=NULL)&&($Combo_Hospital_type==NULL)&&($Combo_P_Province==NULL))
{
$sql="SELECT M_CUSTOMER_CONTACT.Customer,M_HOSPITAL.MPH_Classification, M_CUSTOMER_CONTACT.Title,M_CUSTOMER_CONTACT.FirstName,M_CUSTOMER_CONTACT.Surname, M_CUSTOMER_CONTACT.Specialty ,M_HOSPITAL.Region FROM M_HOSPITAL INNER JOIN M_CUSTOMER_CONTACT ON M_HOSPITAL.[Hospital_Code]=M_CUSTOMER_CONTACT.[Customer] Where Specialty='$Combo_Specialty'";
$sql_statement = odbc_exec($conn,$sql) or die("Not execute Statement");
while($objResult=odbc_fetch_array($sql_statement))
{
?>
<tr>
<td width="60"><div align="left"><?=$objResult["Title"];?></div></td>
<td width="140"><div align="left"><?=$objResult["FirstName"];?></div></a></td>
<td width="180"><div align="left"><?=$objResult["Surname"];?></div></td>
<td width="180"><div align="left"><?=$objResult["Specialty"];?></div></ a></td>
<td width="300"><div align="left"><?=$objResult["MPH_Classification"];?></div></ a></td>
</tr>
<?
}
}else if(($Combo_Specialty==NULL)&&($Combo_Hospital_type!=NULL)&&($Combo_P_Province==NULL))
{
$sql="SELECT M_CUSTOMER_CONTACT.Customer,M_HOSPITAL.MPH_Classification,M_CUSTOMER_CONTACT.Title,M_CUSTOMER_CONTACT.FirstName,M_CUSTOMER_CONTACT.Surname,M_CUSTOMER_CONTACT.Specialty,M_HOSPITAL.Region FROM M_HOSPITAL INNER JOIN M_CUSTOMER_CONTACT ON M_HOSPITAL.[Hospital_Code]=M_CUSTOMER_CONTACT.[Customer] Where MPH_Classification='$Combo_Hospital_type'";
$sql_statement = odbc_exec($conn,$sql) or die("Not execute Statement");
while($objResult=odbc_fetch_array($sql_statement))
{
?>
<tr>
<td width="60"><div align="left"><?=$objResult["Title"];?></div></td>
<td width="140"><div align="left"><?=$objResult["FirstName"];?></div></a></td>
<td width="180"><div align="left"><?=$objResult["Surname"];?></div></td>
<td width="180"><div align="left"><?=$objResult["Specialty"];?></div></ a></td>
<td width="300"><div align="left"><?=$objResult["MPH_Classification"];?></div></ a></td>
</tr>
<?
}
}else if(($Combo_Specialty==NULL)&&($Combo_Hospital_type==NULL)&&($Combo_P_Province!=NULL))
{
if($Combo_P_Province==1)
{
$sql="SELECT M_CUSTOMER_CONTACT.Customer,M_HOSPITAL.MPH_Classification,M_CUSTOMER_CONTACT.Title, M_CUSTOMER_CONTACT.FirstName,M_CUSTOMER_CONTACT.Surname, M_CUSTOMER_CONTACT.Specialty,M_HOSPITAL.Region FROM M_HOSPITAL INNER JOIN M_CUSTOMER_CONTACT ON M_HOSPITAL.[Hospital_Code] =M_CUSTOMER_CONTACT.[Customer] Where Region='TH-T01'";
$sql_statement = odbc_exec($conn,$sql) or die("Not execute Statement");
while($objResult=odbc_fetch_array($sql_statement))
{
?>
<tr>
<td width="60"><div align="left"><?=$objResult["Title"];?></div></td>
<td width="140"><div align="left"><?=$objResult["FirstName"];?></div></a></td>
<td width="180"><div align="left"><?=$objResult["Surname"];?></div></td>
<td width="180"><div align="left"><?=$objResult["Specialty"];?></div></ a></td>
<td width="300"><div align="left"><?=$objResult["MPH_Classification"];?></div></ a></td>
</tr>
<?
}
}else if($Combo_P_Province==2)
{
$sql="SELECT M_CUSTOMER_CONTACT.Customer,M_HOSPITAL.MPH_Classification,M_CUSTOMER_CONTACT.Title, M_CUSTOMER_CONTACT.FirstName,M_CUSTOMER_CONTACT.Surname, M_CUSTOMER_CONTACT.Specialty,M_HOSPITAL.Region FROM M_HOSPITAL INNER JOIN M_CUSTOMER_CONTACT ON M_HOSPITAL.[Hospital_Code]= M_CUSTOMER_CONTACT.[Customer] Where Region='TH-T02'";
$sql_statement = odbc_exec($conn,$sql) or die("Not execute Statement");
while($objResult=odbc_fetch_array($sql_statement))
{
?>
<tr>
<td width="60"><div align="left"><?=$objResult["Title"];?></div></td>
<td width="140"><div align="left"><?=$objResult["FirstName"];?></div></a></td>
<td width="180"><div align="left"><?=$objResult["Surname"];?></div></td>
<td width="180"><div align="left"><?=$objResult["Specialty"];?></div></ a></td>
<td width="300"><div align="left"><?=$objResult["MPH_Classification"];?></div></ a></td>
</tr>
<?
}
}
}
}
?>
</table>
</body>
</html>
Tag : PHP, Ms Access
|
|
|
|
|
|
Date :
2012-05-21 11:21:42 |
By :
NooFonPHP |
View :
955 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องรันโค้ดชุดนี้ แล้ว จับภาพหน้าจอ และ คลิ๊กเมาส์ขวาเลือก view page source แล้วเอามาวางให้ดูหน่อย
|
|
|
|
|
Date :
2012-05-21 11:48:28 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<title>headFindDoctor</title>
</head>
<body>
<br>
<form name="findDoctor" method="post" target="_self" action="FindSpecialty.php">
<table align="center" border="1">
<tr><td align="right">Specialty :</td>
<td align="left"><select name='Combo_Specialty' width='100' height='18'><option value=''></option><option value=Dental>Dental</option><option value=ENT - (Otolaryngology)>ENT - (Otolaryngology)</option><option value=General Practice (GP)>General Practice (GP)</option><option value=Internal Med>Internal Med</option><option value=Internal Med - Dermatology>Internal Med - Dermatology</option><option value=Internal Med - Infectious Diseases>Internal Med - Infectious Diseases</option><option value=Internal Med - Neurology>Internal Med - Neurology</option><option value=Internal Med - Pulmonary & Critical Care Medicine>Internal Med - Pulmonary & Critical Care Medicine</option><option value=Internal Med - Rheumatology>Internal Med - Rheumatology</option><option value=Ob-Gyn - (Obstetrics & Gynaecology)>Ob-Gyn - (Obstetrics & Gynaecology)</option><option value=Ob-Gyn - Oncology>Ob-Gyn - Oncology</option><option value=Ob-Gyn - STD Clinic>Ob-Gyn - STD Clinic</option><option value=Orthopaedics>Orthopaedics</option><option value=Radiology - Radiotherapy & Oncology>Radiology - Radiotherapy & Oncology</option><option value=Rehabilitation Medicine (PMR)>Rehabilitation Medicine (PMR)</option><option value=Surgery - (General)>Surgery - (General)</option><option value=Surgery - Colon & Rectal Surgery>Surgery - Colon & Rectal Surgery</option><option value=Surgery - Neurological Surgery>Surgery - Neurological Surgery</option><option value=Surgery - Pediatric Surgery>Surgery - Pediatric Surgery</option></select></td>
<td rowspan="2"><input type="submit" width="100" height="100" value="FIND" name="Find"/></td>
</tr>
<tr><td align="right">Hospital Type : </td>
<td align="left"><select name='Combo_Hospital_type' width='100' height='18'><option value=''></option><option value=บริการเฉพาะโรค>บริการเฉพาะโรค</option><option value=บริการทั่วไป>บริการทั่วไป</option><option value=โรงพยาบาลชุมชน >โรงพยาบาลชุมชน </option><option value=โรงพยาบาลทหาร>โรงพยาบาลทหาร</option><option value=โรงพยาบาลทั่วไป>โรงพยาบาลทั่วไป</option><option value=โรงพยาบาลศูนย์>โรงพยาบาลศูนย์</option><option value=โรงเรียนแพทย์>โรงเรียนแพทย์</option><option value=ศูนย์การแพทย์ในมหาวิทยาลัยที่ไม่ได้ผลิตแพทย์>ศูนย์การแพทย์ในมหาวิทยาลัยที่ไม่ได้ผลิตแพทย์</option></select></td>
</tr>
<tr><td align="right">BKK/UPC : </td>
<td align="left"><select name='Combo_P_Province' width='100' height='18'><option value='0'></option><option value='1'>BKK</option><option value='2'>UPC</option></select></td>
</tr>
</table>
</form>
<br/></dl></dl>
<table width="100%" border="1" align="center">
<tr bgcolor="#CC0000">
<td size="25" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="80" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="80" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="50" height="22"><font color="white"> <div align="center"></div></font></td>
<td size="200" height="22"><font color="white"> <div align="center"></div></font></td>
</tr>
</table>
</body>
</html>
|
|
|
|
|
Date :
2012-05-21 11:57:55 |
By :
NooFonPHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเปลี่ยนจาก NULL เป็น "" ทุกตัวเลยน่ะครับ
ตัวอย่าง
if(($Combo_Specialty==NULL)&&($Combo_Hospital_type==NULL)&&($Combo_P_Province==NULL))
เป็น
if(($Combo_Specialty=="")&&($Combo_Hospital_type=="")&&($Combo_P_Province==""))
|
|
|
|
|
Date :
2012-05-21 12:21:46 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|