如何修改数据库中内容
运行这段代码时存在一定问题,如图。
<?php
//######################修改课题界面3##########################
include "config.php";
include "admin_header.php";
?>
<title>修改课题</title>
<?php
$query="update $jiaoshi_table set subject='$subject1' where id='$id'";
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query="update $jiaoshi_table set teacher='$teacher1' where id='$id'";
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query=mysql_query("update $jiaoshi_table set zhicheng='$zhicheng1' where id='$id'");
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query=mysql_query("update $jiaoshi_table set specialized='$specialized1' where id='$id'");
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query=mysql_query("update $jiaoshi_table set code='$select' where id='$id'");
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query="update $jiaoshi_table set beizhu='$introduction' where id='$id'";
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$query="select number as sn,surplus as ssn from $jiaoshi_table where id='$id'";
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if($number1<$row[sn])
{
if($number1<($row[sn]-$row[ssn]))
{
echo"<p align="center"><font color="#FF0000"><b><big>人数不能少于现已选题人数,人数列修改失败!</big></b></font>";
echo"<meta http-equiv="refresh" content="2;url=alter_keti.php">";
exit;
}
else
{
$query2=mysql_query("update $jiaoshi_table set number='$number1' where id='$id'");
$query3=mysql_query("update $jiaoshi_table set surplus=surplus-($row[sn]-$number1) where id='$id'");
mysql_query("set names 'GB2312'");
$result1=mysql_query($query3);
}
}
else
{
$query4=mysql_query("update $jiaoshi_table set number='$number1' where id='$id'");
$query5=mysql_query("update $jiaoshi_table set surplus=surplus+($number1-$row[sn]) where id='$id'");
mysql_query("set names 'GB2312'");
$result2=mysql_query($query5);
}
if($result==true)
{
echo"<p align="center"><font color="#FF0000"><b><big>修改课题成功!</big></b></font>";
echo "<meta http-equiv="refresh" content="1;url=alter_keti.php">";
exit;
}
else
{
echo"<p align="center"><font color="#FF0000"><b><big>修改出错,请返回重新修改</big></b></font></p>";
echo "<meta http-equiv="refresh" content="1;url=alter_keti.php">";
exit;
}
?>
<?php include "foot.php";?>