如何在PHP中更新记录? [英] how can update records in php ?
本文介绍了如何在PHP中更新记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个文件edit.php和editpro.php
in edit.php
i have 2 file edit.php and editpro.php
in edit.php
<body>
<form action="editpro.php" method="post">
include "conn.php";
$sql="select * from stud where id=".$_GET['id']."";
$result=mysql_query($sql);
$res=mysql_fetch_row($result);
?>
<table align="center" border="2">
<tr>
<td>Name:</td>
<td><input type="text" name="nm1" value=" <?php echo $res[1]; ??>"</td>
</tr>
<tr>
<td>m1:</td>
<td><input type="text" name="m11" value=" <?php echo $res[2]; ??>"</td>
</tr>
<tr>
<td>m2:</td>
<td><input type="text" name="m21" value=" <?php echo $res[3]; ??>"</td>
</tr>
<tr>
<td>m3:</td>
<td><input type="text" name="m31" value=" <?php echo $res[4]; ??>"</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="sub" value="Update" /></td>
</tr>
</table>
</form>
</body>
in editpro.php...........................................
<?php
ob_start();
include("conn.php");
$id=$_POST['id'];
$name=$_POST['nm1'];
$m1=$_POST['m11'];
$m2=$_POST['m21'];
$m3=$_POST['m31'];
$sql="UPDATE stud SET name='".$name."',m1='".$m1."',m2='".$m2."',m3='".$m3."' where id='".$id."'";
$result=mysql_query($sql);
header("location:p1.php");
?>
此代码中未显示错误但仍然无法更新我的记录...................
No error displayed in this code but still i can't update my record...................
推荐答案
sql =select *来自stud,其中id =。
sql="select * from stud where id=".
_GET ['id']。;
_GET['id']."";
result = mysql_query(
result=mysql_query(
这篇关于如何在PHP中更新记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文