|
|
|
ค้นหาข้อมูลจ้าช่วยทีจ้า list box 2 ชั้นค่ะ เมื่อเลือกกรุงเทพก็จะแสดง ประมาณว่ากรอกอันไหนก็แสดงเหมือนกันอ่ะค่ะช่วยที่นะค่ะ |
|
|
|
|
|
|
|
ช่วยที่ค่ะคือต้องการให้เมือกรอกข้อมูลต้องไหนก็ได้ กรอกไม่ครบก็ เช่น กรอกที่จังหวัดเป็นกรุงเทพข้อมูลก็จะแสดงประมาณที่ค่ะแต่ตอนนี้มันไม่แสดงค่ะใครทราบช่วยทีนะค่ะ
Code (PHP)
<?
ob_start();
?>
<?
session_start();
$_SESSION['username']=$username;
$_SESSION['user_name']=$user_name;
$_SESSION['user_surname']=$user_surname;
$_SESSION['$user_type']=$user_type;
?>
<?
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("training_system");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.back_ground {background-image: url(image/back_ground.jpg);
}
.back_ground {background-image: url(image/back_ground.jpg);
}
.back_ground {background-image: url(image/back_ground.gif);
}
.back_ground {background-image: url(image/back_ground.jpg);
}
.back_ground {background-image: url(image/back_ground.jpg);
}
.back_table {background-color: #F4F4F4;
}
.back_table {background-color: #EEEFFB;
}
.back_table {background-color: #F7F7F7;
}
.back_table {background-color: #E5E5E5;
}
.back_table {background-color: #EEEEEE;
}
.style1 {font-family: "Angsana New";
font-size: 20px;
font-weight: bold;
}
.style36 {font-family: "Angsana New"; font-size: 20px; }
.table {border: thin double #EAEAEA;
}
.style41 {font-size: 20px}
#Layer1 {
position:absolute;
left:578px;
top:545px;
width:235px;
height:182px;
z-index:1;
}
#Layer2 {
position:absolute;
left:569px;
top:534px;
width:157px;
height:140px;
z-index:1;
}
.style42 {font-family: "Angsana New"; font-size: 20px; color: #FFFFFF; }
#Layer3 {
position:absolute;
left:504px;
top:544px;
width:259px;
height:214px;
z-index:1;
}
.style43 {font-family: "Angsana New"}
.style24 {color: #333333}
.style35 {color: #000000; font-weight: bold;}
.style44 {color: #000000}
-->
</style>
<script language="javascript">
function ListAmphur(SelectValue){
//frmMain.Amphur.options[frmMain.Amphur.length]= myOption;
//document.frmMain.Amphur[document.frmMain.Amphur.options.length] = myOption;
frmMain.Amphur.options.length= 0;
/*
if (frmMain.Amphur.options.length > 0){
frmMain.Amphur.remove(0);
}
*/
<?
$intRows = 0;
$strSQL = "SELECT * FROM company";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$p_code = $objResult["com_province"];
$p_name = $objResult["com_amphur"];
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = '<?=$p_code;?>';
strValue = '<?=$p_name;?>';
strItem = '<?=$p_name;?>';
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.Amphur.options[frmMain.Amphur.length]= myOption;
}
<?
}
?>
//document.frmMain.Amphur[document.frmMain.Amphur.length] = myOption;
}
</script>
</head>
<body>
<center>
<?
if($user_type == "student"){
?>
<table width="1063" border="0" cellpadding="0" cellspacing="0" class="back_ground">
<!--DWLayoutTable-->
<tr>
<td width="32" height="20"></td>
<td width="240"></td>
<td width="9"></td>
<td width="117"></td>
<td width="502"></td>
<td width="118"></td>
<td width="9"></td>
<td width="36"></td>
</tr>
<tr>
<td height="205"></td>
<td colspan="6" valign="top"><img src="image/benner.jpg" width="995" height="205" /></td>
<td></td>
</tr>
<tr>
<td height="174"></td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="back_table">
<!--DWLayoutTable-->
<tr>
<td height="56" colspan="5" valign="top"><img src="image/butt_system_new.jpg" width="240" height="56" /></td>
</tr>
<tr>
<td width="9" height="28"> </td>
<td width="9"> </td>
<td width="96" valign="top"><div align="left"><span class="style1"><img src="image/mm_arrow.gif" width="4" height="7" /> ชื่อ</span></div></td>
<td colspan="2" valign="top"><span class="style1"><?echo"$user_name ";?></span></td>
</tr>
<tr>
<td height="28"> </td>
<td> </td>
<td valign="top"><div align="left"><span class="style1"><img src="image/mm_arrow.gif" width="4" height="7" /> นามสกุล</span></div></td>
<td colspan="2" valign="top"><span class="style1"><?echo"$user_surname ";?></span></td>
</tr>
<tr>
<td height="28"> </td>
<td> </td>
<td valign="top"> <div align="left"><span class="style36"><strong><img src="image/mm_arrow.gif" width="4" height="7" /> รหัสประจำตัว</strong></span></div></td>
<td colspan="2" valign="top"><span class="style1"><?echo"$username ";?></span></td>
</tr>
<tr>
<td height="34" bgcolor="#F4F4F4"> </td>
<td colspan="3" valign="top" bgcolor="#F4F4F4"><span class="style41"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><a href="logout.php" class="style24"> <span class="style35">ออกจากระบบ</span></a></span></span></td>
<td width="120" valign="top" bgcolor="#F4F4F4"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> <a href="pass_change.php" class="style44">เปลี่ยน Password</a></strong></span></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td width="6"></td>
<td></td>
</tr>
</table></td>
<td> </td>
<td> </td>
<td rowspan="3" valign="top">
<Form action="student_search.php" name="frmMain" method="POST" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="28" colspan="3" valign="top" bgcolor="#C6CAEF"><div align="center" class="style36"><strong>ค้นหาสถานประกอบการ</strong></div></td>
</tr>
<tr>
<td width="72" height="22"> </td>
<td width="180" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="250" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top"><div align="left"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> ชื่อบริษัท </strong></span></div></td>
<td valign="top"><div align="left">
<input name="txt_search" type="text" value="<?=$_POST['txt_search']?>" size="20" />
</div></td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top"><div align="left"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> จังหวัด </strong></span></div></td>
<td valign="top"><div align="left">
<select id="Province" name="Province" onchange = "ListAmphur(this.value)" value="<?=$_POST['Province']?>" >
<option selected="selected" value=""><-----เลือกจังหวัด-----></option>
<?
$strSQL = "SELECT DISTINCT com_province FROM company";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["com_province"];?>">
<?=$objResult["com_province"];?>
</option>
<?
}
?>
</select>
</div></td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top"><div align="left"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> อำเภอ/เขต </strong></span></div></td>
<td valign="top"><div align="left">
<select id="Amphur" name="Amphur" style="width:100px">
</select>
</div></td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top"><div align="left"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> สาขา</strong></span></div></td>
<td valign="top"><div align="left">
<select name="select2">
<option><-----Menu-----></option>
</select>
</div></td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top"><div align="left"><span class="style36"><img src="image/mm_arrow.gif" width="4" height="7" /><strong> ประเภทงาน </strong></span></div></td>
<td valign="top"><div align="left">
<select name="select">
<option><-----Menu-----></option>
</select>
</div></td>
</tr>
<tr>
<td height="7"></td>
<td></td>
<td></td>
</tr>
</table>
<div align="center">
<input type="submit" name="Search" value="ค้นหา" />
</div>
</form></td>
<td> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="22"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="25"></td>
<td rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--DWLayoutTable-->
<tr>
<td width="240" height="54" valign="top"><img src="image/contents .jpg" width="240" height="54" /></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><strong><img src="image/mm_arrow.gif" width="4" height="7" /> <strong><a href="student_search.php" class="style44">ค้นหาสถานประกอบการ</a></strong></strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><img src="image/mm_arrow.gif" width="4" height="7" /> <strong><a href="student_complaint.php" class="style44">สถานประกอบการที่ต้องการยื่นคำร้อง</a></strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><img src="image/mm_arrow.gif" width="4" height="7" /> <strong><a href="student_biography.php" class="style44">ประวัตินักศึกษาฝึกงาน</a> </strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><img src="image/mm_arrow.gif" width="4" height="7" /> <strong>แก้ไขประวัติส่วนตัว</strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><img src="image/mm_arrow.gif" width="4" height="7" /> <strong> <a href="student_assess.php" class="style44">ผลการประเมิน</a></strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28" valign="top"><table width="240" height="26" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="27" valign="top" bgcolor="#EEEEEE" class="style36"><!--DWLayoutEmptyCell--> </td>
<td width="231" valign="top" bgcolor="#EEEEEE" class="style36"><div align="left"><img src="image/mm_arrow.gif" width="4" height="7" /> <strong> <a href="student_inform.php" class="style44">แจ้งเรื่อง </a></strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="56"> </td>
</tr>
<!--DWLayoutTable-->
</table></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="47"></td>
<td></td>
<td></td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="28"></td>
<td> </td>
<td colspan="3" valign="top" bgcolor="#C6CAEF"><div align="left" class="style1"><----- ผลลัพธ์ </div></td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="74"></td>
<td colspan="5" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="9" height="28"><div align="center"><span class="style41"></span></div></td>
<td width="119" valign="top" bgcolor="#5664CF"><div align="center" class="style42">
<div align="center"><strong>ลำดับ</strong></div>
</div></td>
<td width="3"> </td>
<td width="322" valign="top" bgcolor="#5664CF"><div align="center" class="style42">
<div align="center"><strong>ชื่อบริษัท</strong></div>
</div></td>
<td width="3"> </td>
<td width="129" valign="top" bgcolor="#5664CF"><div align="center" class="style42">
<div align="center"><strong>เบอร์โทรศัพท์</strong></div>
</div></td>
<td width="3"> </td>
<td width="159" valign="top" bgcolor="#5664CF"><div align="center" class="style42">
<div align="center"><strong>รายละเอียด</strong></div>
</div></td>
<td width="9"> </td>
</tr>
<?
if($_POST['Search'])
{
$txt_search = $_POST['txt_search'];
$sql_show.="select * from company where com_name like '%$txt_search%' and com_name='$txt_search' ";
}
if($_POST['Search'])
{
$Province = $_POST['Province'];
$sql_show.="select * from company where com_province like '%$Province%' and com_province='$Province' ";
}
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td height="28"><div align="center"><span class="style41"></span></div></td>
<td valign="top"><div align="center"><span class="style41"><span class="style43"><span class="style41"><span class="style41"></span></span></span></span></div></td>
<td> </td>
<td valign="top"><div align="center"><span class="style41"><span class="style43"><span class="style41"><span class="style41"></span></span></span></span><?=$row_show['com_name']?></div></td>
<td> </td>
<td valign="top"><div align="center" class="style36">
<div align="center"><?=$row_show['com_tel']?></div>
</div></td>
<td> </td>
<td valign="top"><div align="center" class="style36">
<div align="center"><a href="student_detail.php"><img src="image/Add.gif" width="27" height="27" border="0" /></a></div>
</div></td>
<td> </td>
</tr>
<?
}
?>
<tr>
<td height="0"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</td>
<td></td>
</tr>
<tr>
<td height="194"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
</tr>
</table>
<?}else{
header("Location: index.php"); exit();}
?>
</center>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS
|
|
|
|
|
|
Date :
2010-09-02 18:58:48 |
By :
pupae010 |
View :
1527 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าจะเขียนแบบนี้อย่าใช้ javascript เลยครับตรง province อะ ใช้การ submit form ธรรมดาๆ ดีกว่า
|
|
|
|
|
Date :
2010-09-03 00:42:08 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|