php怎么在数据库表里每条后面添加删除和修改程序,代码加在哪里

qq_34506176 2016-04-01 01:36:36
<div align="center">
<form id="form1" name="form1" method="post" action="luru.php" style="background-image:url(images/richu-007.jpg); background-repeat:no-repeat; background-position:center; width:500;">
<p align="center" >学生信息管理系统-新生录入</p>
<table border="1" align="center">
<tr>
<td width="101" >
<b><p align="center">输入学号:</p></b>
</td>
<td width="199" >
<input type="text" name="id" id="id" >

</td>
<tr>
<td width="101" ><b><p align="center">输入姓名:</p></b></td>
<td width="199">
<input name="name" type="text" id="name" >
</td>
</tr>
<td width="101" ><b><p align="center">输入密码:</p></b></td>
<td width="199">
<input type="password" name="mima" id="mima" >

</td>
</tr>
<tr>
<td width="101" >
<b><p align="center">性   别:</p></b>
</td>
<td width="199" ><input type="radio" name="sex" id="radio" value="男">

<input type="radio" name="sex" id="radio2" value="女">
女</td>
</tr>
<tr>
<td width="101" >
<p align="center"><strong>联系手机:</strong></p>
</td>
<td width="199" >
<label>
<input type="text" name="shouji" id="shouji" >
</label>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" >
<input type="submit" name="button" id="button" value="录入" >
<input type="reset" name="button2" id="button2" value="清除" >
</td>
</tr>
</table>
<p align="center"><a href="bdsj.php">查询表单数据</a></p>
</form>
</div>
<?php
$con = mysql_connect("localhost","root","123456");
mysql_query("set names 'utf8'");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xuesheng", $con);
$sql="INSERT INTO body (id,name,mima,sex,shouji)
VALUES
('$_POST[id]','$_POST[name]','$_POST[mima]','$_POST[sex]','$_POST[shouji]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "录入成功";

mysql_close($con)

?>
<?php
$con = mysql_connect("localhost","root","123456");
mysql_query("set names 'utf8'");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("xuesheng", $con);

$result = mysql_query("SELECT * FROM body");

echo "<table align=center border='1' background=images/richu-007.jpg>
<tr >
<th colspan=6 align=center><a size=20>用户数据表单</a></th></tr>
<tr><td align=center width=100>编号</td>
<td align=center width=100>姓名</td>
<td align=center width=100>密码</td>
<td align=center width=100>性别</td>
<td align=center width=100>手机</td>
<td align=center width=100>删除</td>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['mima'] . "</td>";
echo "<td>" . $row['sex'] . "</td>";
echo "<td>" . $row['shouji'] . "</td>";

}
echo "</table>";

mysql_close($con)

?>
...全文
135 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧