|
|
|
ทำ list box 2 อันเชื่อมกันคล้ายๆ เลือกจังหวัดแล้ว list box อีกอันก็จะโชว์ อำเภอขึ้นมา |
|
|
|
|
|
|
|
ลองประยุกต์ใช้แล้วมันไม่ขึ้นอ่าค่ะ ช่วยหน่อยนะค่ะ
หน้าแรก
Code (C#)
<? session_start();
//echo $_SESSION['class_'];
?>
<?php require_once('../Connections/pp.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
//echo $_SESSION['cl'];
$colname_a = "-1";
if (isset($_SESSION['id_a'])) {
$colname_a = (get_magic_quotes_gpc()) ? $_SESSION['id_a'] : addslashes($_SESSION['id_a']);
}
mysql_select_db($database_pp, $pp);
$query_a = sprintf("SELECT * FROM tb_adv WHERE id_advi = '%s' ", $colname_a);
$a = mysql_query($query_a, $pp) or die(mysql_error());
$row_a = mysql_fetch_assoc($a);
$totalRows_a = mysql_num_rows($a);
//echo ;
$r = $row_a['class_'];
mysql_select_db($database_pp, $pp);
$query_r_stu = "SELECT * FROM adv_data where class_ = '$r' and status ='0' ";
$r_stu = mysql_query($query_r_stu, $pp) or die(mysql_error());
$row_r_stu = mysql_fetch_assoc($r_stu);
$totalRows_r_stu = mysql_num_rows($r_stu);
//$cs=$row_r_stu['class_'];
//$rs=$row_a['class_'];
//$rr=$row_r_stu['class_'];
//echo $r;
$rr=$_SESSION['id_a'];
mysql_select_db($database_pp, $pp);
$query_t = "SELECT * FROM adv_data WHERE id = '$rr' ";
$t = mysql_query($query_t, $pp) or die(mysql_error());
$row_t = mysql_fetch_assoc($t);
$totalRows_t = mysql_num_rows($t);
$EE=$row_t['id_advis'];
$cl = $row_t['class_'];
mysql_select_db($database_pp, $pp);
$query_teach = "SELECT * FROM tb_class where name_class = '$cl' ";
$teach = mysql_query($query_teach, $pp) or die(mysql_error());
$row_teach = mysql_fetch_assoc($teach);
$totalRows_teach = mysql_num_rows($teach);
mysql_select_db($database_pp, $pp);
$query_rs_class = "SELECT * FROM tb_class where id_tech ='$EE' ";
$rs_class = mysql_query($query_rs_class, $pp) or die(mysql_error());
$row_rs_class = mysql_fetch_assoc($rs_class);
$totalRows_rs_class = mysql_num_rows($rs_class);
session_start();
include("check_login.php");
?>
<HTML><!-- InstanceBegin template="/Templates/tem_sd_1.dwt" codeOutsideHTMLIsLocked="false" -->
<HEAD>
<!-- InstanceBeginEditable name="doctitle" -->
<TITLE>ยินดีต้อนรับเข้าสู่ -ระบบอาจารย์ที่ปรึกษา-</TITLE>
<!-- InstanceEndEditable -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link rel="stylesheet" href="../main.css" type="text/css">
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script><style type="text/css">
<!--
body {
background-color: #C0C0C0;
}
body,td,th {
font-size: 12px;
color: #336600;
font-weight: bold;
}
a {
font-size: 12px;
color: #336600;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</HEAD>
<BODY >
<div align="center">
<table width="778" border="0" cellspacing="0" cellpadding="0" background="../images/index_04.gif">
<tr>
<td width="71"><?
echo "<a href=../$web><img border=0 src='../images/index_01.gif'</a>";
?></td>
<td width="74"> </td>
<td width="470"> </td>
<td width="163"> </td>
</tr>
</table>
<table width="778" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="778"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','778','height','136','src','../images/1','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../images/1' ); //end AC code
</script>
<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="778" height="136">
<param name="movie" value="../images/1.swf">
<param name="quality" value="high">
<embed src="../images/1.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="778" height="136"></embed>
</object></noscript></td>
</tr>
</table>
<table width="778" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="14" background="../images/index_23.gif"><img src="../images/index_08.gif" width=14 height=54 alt=""></td>
<td>
<table width="764" border="0" cellspacing="0" cellpadding="0">
<!--DWLayoutTable-->
<tr valign="top">
<td width="141" colspan="2" valign="top" bgcolor="#FFFFFF"><p>
<?
include("../include/conf.php");
$id1=$_SESSION['id_a'];
$status=$_SESSION['status'];
echo "คุณ ",$_SESSION['fname']," ",$_SESSION['lname'],"<br>";
echo $_SESSION['id_a'],"<br>";
echo "หมู่เรียน",$_SESSION['class_'],"<br>";
echo "E-Mail ",$_SESSION['e-mail'],"<br>";
?>
</p>
<p><a href="selectshow.php">ข้อความส่วนตัว</a>
<?
$id_st=$_SESSION['id_a'];
$sqlss = "select * from consul where id_st='$id_st' and active='1'";
$db_queryss = mysql_query($sqlss);
$num_rows = mysql_num_rows($db_queryss);
if ($num_rows > 0){
echo "มีข้อความใหม่";
}
?>
</p>
<p><a href="../register/viw_re.php?id=<? echo "$id1";?>">แก้ไขข้อมูลส่วนตัว</a></p>
<p><a href="../report/index.php">รายงาน</a></p>
<p> </p></td>
<td width="542" rowspan="2" valign="top" background="../images/index_35.gif">
<table width="542" border="0" cellspacing="0" cellpadding="0" background="../images/index_15.gif">
<tr>
<td width="542"><a href="../webboard/index.php"><img src="../images/024_10.gif" width=99 height=45 alt="" border="0"></a><a href="consultation.php"><img src="../images/024_11.gif" width=79 height=45 alt="" border="0"></a><a href="../history/seek.php"><img src="../images/024_12.gif" width=78 height=45 alt="" border="0"></a><a href="../student/main.php"><img src="../images/024_13.gif" width=105 height=45 alt="" border="0"><img src="../images/024_14.gif" width=90 height=45 alt="" border="0"></a><a href="../logout.php"><img src="../images/024_15.gif" width=91 height=45 alt="" border="0"></a></td>
</tr>
</table>
<table width="542" height="569" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="542" valign="top"><!-- InstanceBeginEditable name="detail" -->
<form id="form1" name="form1" method="post" action="saves.php">
<?
$status=$_SESSION['status'];
$id1=$_SESSION['id_a'];
?>
<p align="center">การให้คำปรึกษา</p>
<table width="528" border="0" align="center">
<tr>
<th width="114" scope="col"><div align="right">หัวข้อเรื่อง:</div></th>
<th colspan="2" scope="col"><div align="left">
<input name="head" type="text" id="head" size="40" />
</div></th>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td><div align="center"><strong>รายละเอียด:</strong></div></td>
<td colspan="2"><textarea name="detail" id="detail" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<?php if ($row_t['status']=='1') { ?>
<? //if (status=='1') { ?>
<tr>
<td height="27"><div align="center"><strong>หมุ่เรียน:</strong></div></td>
<td width="154"><label>
<select name="select" id="select" title="<?php echo $row_rs_class['name_class']; ?>" >
<?php
do {
?>
<option value="<?php echo $row_rs_class['name_class']?>"><?php echo $row_rs_class['name_class']?></option>
<?php
} while ($row_rs_class = mysql_fetch_assoc($rs_class));
$rows = mysql_num_rows($rs_class);
if($rows > 0) {
mysql_data_seek($rs_class, 0);
$row_rs_class = mysql_fetch_assoc($rs_class);
}
?>
</select>
</label>
<?php
do {
?></td>
<option value="<?php echo $row_rs_class['name_class']?>"<?php if (!(strcmp($row_rs_class['name_class'], $row_a['class_']))) {echo "selected=\"selected\"";} ?>></option>
<?php
} while ($row_rs_class = mysql_fetch_assoc($rs_class));
$rows = mysql_num_rows($rs_class);
if($rows > 0) {
mysql_data_seek($rs_class, 0);
$row_rs_class = mysql_fetch_assoc($rs_class);
}
?>
</tr>
<tr>
<td><div align="center"><strong>ถึงนักศึกษาในที่ปรึกษา:</strong></div></td>
<td colspan="2"><label>
<select name="id_stu" id="id_stu">
<option value="0" <?php if (!(strcmp(0, $row_r_stu['fname']))) {echo "selected=\"selected\"";} ?>>--เลือก--</option>
<?php
do {
?><option value="<?php echo $row_r_stu['fname']?>"<?php if (!(strcmp($row_r_stu['fname'], $row_r_stu['fname']))) {echo "selected=\"selected\"";} ?>><?php echo $row_r_stu['fname']?></option><?php
} while ($row_r_stu = mysql_fetch_assoc($r_stu));
$rows = mysql_num_rows($r_stu);
if($rows > 0) {
mysql_data_seek($r_stu, 0);
$row_r_stu = mysql_fetch_assoc($r_stu);
}
?>
</select>
</label></td>
</tr>
<? } else { ?>
<tr>
<td> </td>
<td><?php echo $row_teach['name_tech']; ?></td>
</tr> <? } ?>
<tr>
<td> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="ส่งข้อมูล" /></td>
</tr>
</table>
<p> </p>
</form>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td height="475" colspan="2" valign="top" bgcolor="#FFFFFF"><table width="222" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="222"><img src="../images/index_32.gif" width=222 height=50 alt=""></td>
</tr>
</table>
<table width="221" border="0" cellspacing="8" cellpadding="0" height="101" background="../images/index_34.gif">
<tr>
<td width="211" valign="top" class="t12_grey"><a href="../class/class_ad.php">ตารางสอน / ตารางเรียน</a><a href="../student/class/class_ad.php"></a></td>
</tr>
</table>
<table width="220" border="0" cellspacing="8" cellpadding="0" height="101" background="../images/index_34.gif">
<tr>
<td width="210" valign="top" class="t12_grey"><a href="http://home.npru.ac.th/webhome/index.html">โฮมเพจอาจารย์</a></td>
</tr>
</table> <table width="220" border="0" cellspacing="8" cellpadding="0" height="101" background="../images/index_34.gif">
<tr>
<td width="210" valign="top" class="t12_grey"><a href="http://ct.npru.ac.th/">โปรแกรมวิชา</a></td>
</tr>
</table></td>
</tr>
</table> </td>
</tr>
</table>
<table width="778" border="0" cellspacing="0" cellpadding="0" height="41" background="../images/index_38.gif">
<tr>
<td align="right" class="t12_white">Nakhon Pathom Rajabhat University</td>
</tr>
</table>
</div>
</BODY>
<!-- InstanceEnd --></HTML>
<?php
mysql_free_result($a);
mysql_free_result($r_stu);
mysql_free_result($t);
mysql_free_result($teach);
mysql_free_result($rs_class);
?>
หน้า save.php
Code (C#)
<p><? $_POST[id_stu]; ?></p>
<?
include "../include/conf.php";
$id=$_GET[id];
$head=$_POST[head];
$detail=$_POST[detail];
echo $n =$_POST['id_stu'];
// $n=$_POST[id_stu];
$id_st=$_SESSION['id_a'];
$email=$_SESSION['email'];
$fname=$_SESSION['fname'];
//echo $id_ad=$_POST[id_ad];
//$id_stu=$_POST[id_stu];
//$to_name=$_POST[id_stu];
//echo $to_name;
$date=date("Y-m-d");
$active = 1;
/*echo $to_name;
exit();*/
//$sqls="select * from adv_data where fname='$to_name'";
//
$sqls="select * from adv_data where id='$to_name' or class_='$to_name' or fname='$to_name'";
/*echo $sqls;
exit();*/
$db_query = mysql_query($sqls);
$num = mysql_num_rows($db_query);
/*echo $num;*/
/*exit();*/
/*$num=1;*/
if($num>0){
$sql="insert into consul value('','$fname','$n','$head','$detail','$date','$active')";
/*echo $sql;
exit();*/
$result=mysql_db_query($db,$sql);
/*if($db_query){
echo "<script language='javascript'>window.opener.location.reload();window.close();</script>";
}
*/
echo "<h3> บันทึกคำตอบเรียบร้อยแล้ว</h3>";
//echo "<meta http-equiv='Refresh' content='3; url=index.php?id=$id'>";
//echo "<a href = 'show_views.php?id=$id'>>>คลิก<<</a><br><br>";
}else{
echo "<h3>ไม่สามารถตั้งคำถามในกระทู้ ถาม - ตอบได้ </h3>";
}
?>
</p>
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2012-06-27 09:01:29 |
By :
กัญญาภัทร |
View :
1880 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|