|
|
|
ช่วยดูโค้ดให้หน่อยค่ะว่าทำไมเราคลิกเลือกชื่อใน list box อันที่สองแล้วทำไมไม่โชว์ชื่อที่เราเลือกให้เหนเลย |
|
|
|
|
|
|
|
Code (C#)
<?
$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="a" id="a" title="<?php echo $row_rs_class['name_class']; ?>" onChange = "ListRoom(this.value)" >
<?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" onChange = "ListRoom(this.value)"/>
<option value="<?=$id_stu?>">
<? if($id_stu){echo"$id";}else if(!$id_stu){echo"เลือก";}?>
</option>
</select>
</label></td>
</tr>
<? } ?>
<tr>
<td> </td>
<td><?php if ($row_t['status']=='0') { echo $row_teach['name_tech'];} ?></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="ส่งข้อมูล" /></td>
</tr>
</table>
<br>
<?
/* ==========================================================================================*/
?>
<script language="javascript" type="text/javascript">
function setage()
{
var selectList = document.frmselect("name");
for (i=0;i<selectList.options.length;i++)
{
selectList.removeChild(selectList.options.item(i));
}
var index_name=document.frmselect.name.selectedIndex;
document.frmselect.age.selectedIndex=index_name;
}
</script>
</form>
<script>
function ListRoom(SelectValue)
{
form1.id_stu.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.id_stu.options[form1.id_stu.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM adv_data ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
var mySubList = new Array();
var strID = <?=$objResult["id"];?>;
var strName = "<?=$objResult["fname"];?>";
var strLastName = "<?=$objResult["lname"];?>";
var status = "<?=$objResult["status"];?>";
mySubList[x,0] = strID;
mySubList[x,1] = strName;
mySubList[x,2] = strLastName;
mySubList[x,3] = status;
if (mySubList[x,3] == 0){
var myOption = new Option(mySubList[x,1], mySubList[x,2])
form1.id_stu.options[form1.id_stu.length]= myOption
}
<?
}
?>
}
</script>
รูปที่1 แสดงตอนเลือกโดยการคลิกที่ชื่อนั้นๆ
รูปที2 เมื่อเลือกแล้วทำไมชื่อที่เลือกไม่ยอมโชว์ ดันโชว์อันแรกที่ไม่มีชื่อ
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2012-07-11 19:23:22 |
By :
pangcs |
View :
820 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<? 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");
?>
อันนี้เป็นโค้ดด้านบนสุดนะค่ะ
|
|
|
|
|
Date :
2012-07-11 19:50:00 |
By :
pangcs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันที่ถูกจะต้องเป็นอะไรครับ
|
|
|
|
|
Date :
2012-07-11 21:40:07 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก้อถ้าคลิกชื่อที่เราเลือกมันต้องโชว์ชื่อใน list box ด้วยอ่าค่ะ แต่เมื่อคลิกที่ชื่อแล้วกลับเป็นดังรูปที่2
|
|
|
|
|
Date :
2012-07-11 22:35:50 |
By :
pangcs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|