001.
<?
002.
include
(
'../Connection/connect.php'
);?>
003.
<html>
004.
<head>
005.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
006.
<?php
007.
008.
mysql_query(
"SET NAMES UTF8"
);?>
009.
<?
010.
$id
=
$branch_id
;
011.
$branch_name
=
$branch_name
;
012.
$faculty_id
=
$faculty_id
;
013.
$faculty_name
=
$faculty_name
;
014.
015.
016.
?>
017.
<script language =
"JavaScript"
>
018.
019.
020.
function
Listfaculty(SelectValue)
021.
{
022.
frmMain.Lfaculty.length = 0
023.
024.
025.
var
myOption =
new
Option(
''
,
''
)
026.
frmMain.Lfaculty.options[frmMain.Lfaculty.length]= myOption
027.
028.
<?
029.
$intRows
= 0;
030.
$strSQL
=
"SELECT * FROM faculty ORDER BY faculty_id ASC "
;
031.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
032.
$intRows
= 0;
033.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
034.
{
035.
$intRows
++;
036.
?>
037.
x = <?=
$intRows
;?>;
038.
mySubList =
new
Array();
039.
040.
strGroup = <?=
$objResult
[
"campus_id"
];?>;
041.
strValue =
"<?=$objResult["
faculty_id
"];?>"
;
042.
strItem =
"<?=$objResult["
faculty_name
"];?>"
;
043.
mySubList[x,0] = strItem;
044.
mySubList[x,1] = strGroup;
045.
mySubList[x,2] = strValue;
046.
if
(mySubList[x,1] == SelectValue){
047.
var
myOption =
new
Option(mySubList[x,0], mySubList[x,2])
048.
frmMain.Lfaculty.options[frmMain.Lfaculty.length]= myOption
049.
}
050.
<?
051.
}
052.
?>
053.
}
054.
055.
056.
</script>
057.
<script language=
"javascript"
>
058.
function
Listbranch(SelectValue)
059.
{
060.
if
(SelectValue !=
""
)
061.
window.location.href=
"view_branch_.php?a="
+SelectValue;
062.
}
063.
</script>
064.
</head>
065.
<body>
066.
067.
<form name=
"frmMain"
action=
""
method=
"post"
>
068.
069.
070.
<div id=
"divResult"
>
071.
<p>
072.
<iframe id=
"iframe_target"
name=
"iframe_target"
src=
"#"
style=
"width:0;height:0;border:0px solid #FFFFFF;"
></iframe>
073.
<script language=
"JavaScript"
type=
"text/javascript"
>
074.
function
showResult(result)
075.
{
076.
if
(result==1)
077.
{
078.
<?
echo
"alert('กรุณาเลือกวิทยาเขต')"
; ?>
079.
080.
}
081.
else
if
(result==2)
082.
{
083.
<?
echo
"alert('กรุณาเลือกคณะ')"
; ?>
084.
085.
}
086.
else
if
(result==3)
087.
{
088.
<?
echo
"alert('กรุณาใส่ชื่อสาขา')"
; ?>
089.
090.
}
091.
else
if
(result==4)
092.
{
093.
<?
echo
"alert('ชื่อสาขานี้มีอยู่แล้ว')"
; ?>
094.
095.
}
096.
else
097.
{
099.
window.location =url;
100.
}
101.
}
102.
</script>
103.
</p>
104.
</div>
105.
106.
107.
<table width=
"361"
border=
"1"
align=
"center"
>
108.
<tr>
109.
<td colspan=
"2"
align=
"center"
>ตรวจสอบชื่อสาขาในแต่ละคณะของแต่ละวิทยาเขต</td>
110.
</tr>
111.
<tr>
112.
<td width=
"84"
>วิทยาเขต</td>
113.
<td width=
"261"
><select id=
"DDLcampus"
name=
"DDLcampus"
onChange =
"Listfaculty(this.value)"
>
114.
<option selected value=
""
>กรุณาเลือก</option>
115.
<?
116.
$strSQL
=
"SELECT * FROM campus ORDER BY campus_id ASC "
;
117.
mysql_query(
"SET NAME UTF8"
);
118.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
119.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
120.
{
121.
?>
122.
<option value=
"<?=$objResult["
campus_id
"];?>"
>
123.
<?=
$objResult
[
"campus_name"
];?>
124.
</option>
125.
<?
126.
}
127.
?>
128.
</select></td>
129.
</tr>
130.
<tr>
131.
<td>คณะ </td>
132.
<td><select id=
"Lfaculty"
name=
"Lfaculty"
style=
"width:120px"
onChange=
"Listbranch(this.value)"
>
133.
<option selected value=
"0"
>กรุณาเลือก</option>
134.
</select></td>
135.
</tr>
136.
</table>
137.
<br>
138.
139.
<p> </p>
140.
<?
141.
if
(isset(
$a
))
142.
{
143.
$sql_show
=
"select * from branch where branch.faculty_id=$a"
;
144.
mysql_query(
"SET NAMES UTF8"
);
145.
$result_show
=mysql_query(
$sql_show
)
or
die
(mysql_error());
146.
$row
= mysql_num_rows(
$result_show
);
147.
if
(
$row
==0)
148.
{
149.
echo
"<font color = red>ไม่พบข้อมูล</font>"
;
150.
}
151.
else
152.
{
153.
?>
154.
<table width=
"427"
border=
"1"
align=
"center"
>
155.
<tr>
156.
<td width=
"41"
align=
"center"
>ลำดับ</td>
157.
<td width=
"299"
align=
"center"
>สาขา</td>
158.
<td colspan=
"2"
align=
"center"
><a href=
"add_branch_.php"
>เพิ่ม</a></td>
159.
</tr>
160.
<?
161.
while
(
$row_show
=mysql_fetch_array(
$result_show
))
162.
{
163.
?>
164.
<tr>
165.
<td align=
"center"
><?=
$row_show
[
'branch_id'
];?></td>
166.
<td align=
"left"
><?=
$row_show
[
'branch_name'
];?></td>
167.
<td width=
"29"
align=
"center"
><a href=
"view_branch_.php?branch_id=<?=$row_show['branch_id'];?>&branch_name=<? echo $branch_name?>"
onclick=
"return chkdel();"
> ลบ</a></td>
168.
<td width=
"30"
align=
"center"
><a href=
" edit_branch.php?branch_id=<?=$row_show['branch_id'];?>"
>แก้ไข</a></td>
169.
</tr>
170.
<?
$i
++;} ?>
171.
<?
172.
}
173.
}
174.
?>
175.
176.
</table>
177.
178.
</form>
179.
<?
180.
if
(
$id
!=
""
){
181.
$sql_del
=
"delete from branch where branch_id=$id"
;
182.
$result_del
=mysql_query(
$sql_del
)
or
die
(mysql_error());
183.
$branch_id
=
""
;
184.
if
(
$result_del
)
185.
{
186.
echo
"<script language=\"javaScript\">"
;
187.
echo
"alert('ข้อมูลถูกลบเรียบร้อบแล้ว !!!');"
;
188.
echo
"</script>"
;
189.
echo
"<meta http-equiv='refresh' content='0; url=view_branch_.php?a'>"
;
190.
}
191.
}
192.
?>
193.
</body>
194.
</html>