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