<td width=160 bgcolor=#CCCCCC>
<div align=center class=STYLE2>请选择专业
</div>
</td>
<td width=139 bgcolor=#CCCCCC>
<select name="s1" onChange="redirec(document.frm.s1.option.selectedIndex)">
<option selected>请选择</option>
<option name="应用物理学">应用物理学</option>
<option name="光信息科学">光信息科学</option>
<option name="地信">地信</option>
<option name="信计">信计</option>
</select>
</td>
<td width=160 bgcolor=#CCCCCC>
<div align=center>
<span class=STYLE2>请选择学号
</span>
</div>
</td>
<td width=149 bgcolor=#CCCCCC>
<select name="s2" onchange="AddStu.php">
<option value="" selected>请选择</option>
</select>
</td>
<td>
<input type="submit" name="Submit" value="确认" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
var select1_len=document.frm.s1.options.length;
var select2=new Array(select1_len);
for(i=0;i<select1_len;i++){
select2[i]=new Array();
}
select2[0][0]=new Option("请选择","");
<?php
require_once 'fun.php';
$sql1="SELECT * FROM xs WHERE 专业名='应用物理学'";
$sql2="SELECT * FROM xs WHERE 专业名='光信息科学'";
$sql3="SELECT * FROM xs WHERE 专业名='地信'";
$sql4="SELECT * FROM xs WHERE 专业名='信计'";
$result1=mysql_query($sql1);
$result2=mysql_query($sql2);
$result3=mysql_query($sql3);
$result4=mysql_query($sql4);
$i=1;$j=1;
while($row1=mysql_fetch_array($result1)){
?>
select2[1][0]=new Option("请选择","");
select2[1][<?php echo $i;?>]=new Option("<?php echo $row1['学号'];?>","<?php echo $row1['学号'];?>");
<?php
$i++;
}
while($row2=mysql_fetch_array($result2)){
?>
select2[2][0]=new Option("请选择","");
select2[2][<?php echo $j; ?>]=new Option("<?php echo $row2['学号'];?>","<?php $row2['学号'];?>");
<?php
$j++;
}
?>
function redirec(x){
var temp=document.frm.s2;
temp.length=0;
temp.options.length=select2[x].length;
for(i=0;i<select2[x].length;i++){
temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
}
temp.options[0].selected=true;
}
</script>
<?php
@session_start();
$number=$_POST['s2'];
为什么这段代码中提示:Notice: Undefined index: s2 in E:\Appserve\wamp\www\XsKc\AddStu.php on line 102
还有二级<select>下为什么在前面的select选择了专业后后面的那个select不能够出现学号,请高手们解决下
<div align=center class=STYLE2>请选择专业
</div>
</td>
<td width=139 bgcolor=#CCCCCC>
<select name="s1" onChange="redirec(document.frm.s1.option.selectedIndex)">
<option selected>请选择</option>
<option name="应用物理学">应用物理学</option>
<option name="光信息科学">光信息科学</option>
<option name="地信">地信</option>
<option name="信计">信计</option>
</select>
</td>
<td width=160 bgcolor=#CCCCCC>
<div align=center>
<span class=STYLE2>请选择学号
</span>
</div>
</td>
<td width=149 bgcolor=#CCCCCC>
<select name="s2" onchange="AddStu.php">
<option value="" selected>请选择</option>
</select>
</td>
<td>
<input type="submit" name="Submit" value="确认" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
var select1_len=document.frm.s1.options.length;
var select2=new Array(select1_len);
for(i=0;i<select1_len;i++){
select2[i]=new Array();
}
select2[0][0]=new Option("请选择","");
<?php
require_once 'fun.php';
$sql1="SELECT * FROM xs WHERE 专业名='应用物理学'";
$sql2="SELECT * FROM xs WHERE 专业名='光信息科学'";
$sql3="SELECT * FROM xs WHERE 专业名='地信'";
$sql4="SELECT * FROM xs WHERE 专业名='信计'";
$result1=mysql_query($sql1);
$result2=mysql_query($sql2);
$result3=mysql_query($sql3);
$result4=mysql_query($sql4);
$i=1;$j=1;
while($row1=mysql_fetch_array($result1)){
?>
select2[1][0]=new Option("请选择","");
select2[1][<?php echo $i;?>]=new Option("<?php echo $row1['学号'];?>","<?php echo $row1['学号'];?>");
<?php
$i++;
}
while($row2=mysql_fetch_array($result2)){
?>
select2[2][0]=new Option("请选择","");
select2[2][<?php echo $j; ?>]=new Option("<?php echo $row2['学号'];?>","<?php $row2['学号'];?>");
<?php
$j++;
}
?>
function redirec(x){
var temp=document.frm.s2;
temp.length=0;
temp.options.length=select2[x].length;
for(i=0;i<select2[x].length;i++){
temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
}
temp.options[0].selected=true;
}
</script>
<?php
@session_start();
$number=$_POST['s2'];
为什么这段代码中提示:Notice: Undefined index: s2 in E:\Appserve\wamp\www\XsKc\AddStu.php on line 102
还有二级<select>下为什么在前面的select选择了专业后后面的那个select不能够出现学号,请高手们解决下
s2 应该是 <select name="s2" onchange="AddStu.php"> 的值吧
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<head>
<title>
学生信息更新
</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 28px;
font-family: "Courier New";
}.STYLE2 {
font-size: 20px;
font-family: "Courier New";
}
-->
</style>
</head>
<body>
<div align=center><span class=STYLE1>学生信息更新</span></div>
<br /><hr width=1000 color=#6699FF />
<form name="frm" method="POST" action="AddStu.php" enctype="multipart/form-date">
<table width=620 border=1 align=center>
<tr>
<td width=160 bgcolor=#CCCCCC>
<div align=center class=STYLE2>请选择专业
</div>
</td>
<td width=139 bgcolor=#CCCCCC>
<select name="s1" onChange="redirec(document.frm.s1.option.selectedIndex)">
<option selected>请选择</option>
<option name="应用物理学">应用物理学</option>
<option name="光信息科学">光信息科学</option>
<option name="地信">地信</option>
<option name="信计">信计</option>
</select>
</td>
<td width=160 bgcolor=#CCCCCC>
<div align=center>
<span class=STYLE2>请选择学号
</span>
</div>
</td>
<td width=149 bgcolor=#CCCCCC>
<select name="s2" onchange="AddStu.php">
<option value="" selected>请选择</option>
</select>
</td>
<td>
<input type="submit" name="Submit" value="确认" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
var select1_len=document.frm.s1.options.length;
var select2=new Array(select1_len);
for(i=0;i<select1_len;i++){
select2[i]=new Array();
}
select2[0][0]=new Option("请选择","");
<?php
require_once 'fun.php';
$sql1="SELECT * FROM xs WHERE 专业名='应用物理学'";
$sql2="SELECT * FROM xs WHERE 专业名='光信息科学'";
$sql3="SELECT * FROM xs WHERE 专业名='地信'";
$sql4="SELECT * FROM xs WHERE 专业名='信计'";
$result1=mysql_query($sql1);
$result2=mysql_query($sql2);
$result3=mysql_query($sql3);
$result4=mysql_query($sql4);
$i=1;$j=1;
while($row1=mysql_fetch_array($result1)){
?>
select2[1][0]=new Option("请选择","");
select2[1][<?php echo $i;?>]=new Option("<?php echo $row1['学号'];?>","<?php echo $row1['学号'];?>");
<?php
$i++;
}
while($row2=mysql_fetch_array($result2)){
?>
select2[2][0]=new Option("请选择","");
select2[2][<?php echo $j; ?>]=new Option("<?php echo $row2['学号'];?>","<?php $row2['学号'];?>");
<?php
$j++;
}
?>
function redirec(x){
var temp=document.frm.s2;
temp.length=0;
temp.options.length=select2[x].length;
for(i=0;i<select2[x].length;i++){
temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
}
temp.options[0].selected=true;
}
</script>
<?php
@session_start();
$number=$_POST['s2'];
$_SESSION['$StuNumber']=$number;
$sql="SELECT * FROM xs WHERE 学号='$number'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$tt=$row['出生日期'];
$timeTemp=strtotime($tt);
$time=date("Y-n-j",$timeTemp);
?>
<form name="frm2" method="POST" enctype="multipart/form-date">
<div align=center>
<table width=620 border=1 align=center>
<tr>
<td width=110 height=30 class=STYLE2 bgcolor=#CCCCCC>学号
</td>
<td width=470 height=30 class=STYLE2 bgcolor=#CCCCCC><?php echo $row['学号'];?>
<input type="hidden" name="StuNumber" value="<?php echo $row['学号'];?>" class=STYLE2 />
</td>
</tr>
<tr>
<td class=STYLE2 height=30 bgcolor=#CCCCCC>姓名
</td>
<td width=470>
<input name="StuName" size=31 type=text value="<?php echo $row['姓名'];?>" class=STYLE2 />
</td>
</tr>
<tr>
<td height=30 bgcolor=#CCCCCC>专业
</td>
<td>
<input type="text" name="Project" size=31 value="<?php echo $row['专业名']?>" class=STYLE2 />
</td>
</tr>
<tr>
<td height=30 bgcolor=#CCCCCC>
<span class=STYLE2>性别
</span>
</td>
<td>
<p>
<?php
//0女1男
if(ord($row['性别'])==0){
?>
<span class=STYLE2>
<input type="radio" name="sex" value="1" />男
</span>
<span class=STYLE2>
<input type="radio" name="sex" value="0" / checked="checked">女
</span>
</p>
</td>
</tr>
<?php
}
else {
?>
<span class=STYLE2>
<input type="radio" name="sex" value="1" checked="checked" />男
</span>
<span class=STYLE2>
<input type="radio" name="sex" value="0" />女
</span>
<?php }?>
<tr>
<td height=30 class=STYLE2 bgcolor=#CCCCCC>出生日期
</td>
<td>
<input type="text" name="Birthday" size=31 value="<?php echo $time;?>" class=STYLE2 />
</td>
</tr>
<tr>
<td height=30 class=STYLE2 bgcolor=#CCCCCC>总学分
</td>
<td>
<input type="text" name="StuZXF" value="<?php echo $row['总学分'];?>" class=STYLE2 />
</td>
</tr>
<tr>
<td height=40 class=STYLE2 bgcolor=#CCCCCC>备注
</td>
<td>
<div width=470>
<textarea cols=30 name="StuBZ" class=STYLE2><?php echo $row['备注'];?></textarea>
</div>
</td>
</tr>
<tr>
<td height=150 class="STYLE2" bgcolor=#CCCCCC>
<div align=center>学生照片
</div>
</td>
<td align=center>
<?php
if($row['照片'])
echo "<img src=\"picture.php?\">";
else
echo "<div class=STYLE2>暂无照片</div>";
?>
<br />
<input type="file" name="file" id="file" />
</td>
</tr>
<tr>
<td height="38" colspan="2" class=STYLE2 bgcolor=#CCCCCC>
<div align=center>
<input type="submit" name="b" class=STYLE2 value="编辑" />
<input name="b" type="button" class=STYLE2 value="新建" onclick="location.href='new.php'" />
<input type="submit" name="b" class=STYLE2 value="删除" />
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<?php
if($_POST['b']=='编辑'){
$StuNumber=$_POST['StuNumber'];
$StuName=$_POST['StuName'];
$Project=$_POST['Project'];
$sex=$_POST['sex'];
$Birthday=$_POST['Birthday'];
$StuZXF=$_POST['StuZXF'];
$StuBZ=$_POST['StuBZ'];
$file=$_FILES["file"]["temp_name"];
}
/*if(!$StuName)
echo "<script>alert('姓名不能为空!');location.href='AddStu.php';</script>";
else if(!$Birthday)
echo "<script>alert('出生日期不能够为空!');location.href='AddStu.php';</script>";
else if($Project!='应用物理系' && $Project!='光信息科学' && $Project!='地信' && $Project!='信计' )
echo "<script>alert('没有此专业!');location.href='AddStu.php';</script>";
else {
if(!$file)
$sql="UPDATE xs SET 姓名='$StuName',专业名='$Project',性别='$sex',总学分='$StuZXF',备注='$StuBZ' WHERE 学号='$StuNumber'";
else {
if((($_FILES['file']['type']!="image/gif")&&($_FILES['file']['type']!="image/jpeg")&& ($_FILES['file']['type']!="image/pjpeg")))
echo "<script>alert('图片格式不对!');location.href='AddStu.php';</script>";
else if($_FILE['file']['size']>64000)
echo "<script>alert('图片太大!');location.href='AddStu.php';</script>";
else {
$PSize=$_FILES['file']['size'];
$mysqlPicture=addslashes(fread(fopen($file,"r"),$PSize));
$sql="UPDATE xs SET 姓名='$StuName' 专业名='$Project',性别='$sex',总学分=$StuZXF,照片='$mysqlPicture',备注='$StuBZ' WHERE 学号='$StuNumber'";
}
}
$result=mysql_query($sql);
if($result)
echo "<script>alert('修改成功!');location.href='AddStu.php';</script>";
else
echo "<script>alert('修改失败!');location.href='AddStu.php';</script>";
}*/if($_POST['b']=='删除'){
$StuNumber=$_POST['StuNumber'];
if(!$StuNumber)
echo "<script>alert('无此人信息!');location.href='AddStu.php';</script>";
else {
$sql="DELETE FROM xs WHERE 学号='$StuNumber' ";
$str="DELETE FROM xs_kc WHERE 学号='$StuNumber'";
$result=mysql_query($sql);
$res=mysql_query($str);
if($result&&$res){
echo "<script>alert('删除成功!');location.href='AddStu.php';</script>";
}
}
}
?>
这是源码