PHP插入数据库代码,编辑,删除
2010-05-24 06:22
281 查看
插入代码
编辑代码
删除代码
<? $action=$_GET['action']; switch($action){ //添加记录 case"add"; $mail = trim(htmlspecialchars($_POST["mail"])); $username = trim(htmlspecialchars($_POST["username"])); $tel = trim(htmlspecialchars($_POST["tel"])); $fax = trim(htmlspecialchars($_POST["fax"])); $company = trim(htmlspecialchars($_POST["company"])); $address = trim(htmlspecialchars($_POST["address"])); $sql="insert into crm_company (mail,username,tel,fax,company,address,addtime) values ('$mail','$username','$tel','$fax','$company','$address','$addtime')"; //echo $sql; mysql_query($sql,$conn); print "<mce:script type="text/javascript"><!-- location.href='c_companylist.php'; // --></mce:script>";//*/ }?>
编辑代码
<? $action=$_GET['action']; switch($action){ //添加记录 case"edit"; $uid = trim(htmlspecialchars($_POST["uid"])); $regtime = trim(htmlspecialchars($_POST["regtime"])); $deadline = trim(htmlspecialchars($_POST["deadline"])); $item = trim(htmlspecialchars($_POST["item2"])); $price = trim(htmlspecialchars($_POST["price"])); $product = trim(htmlspecialchars($_POST["product"])); $content = trim(htmlspecialchars($_POST["content"])); $sql="update crm_info set uid='$uid',regtime='$regtime',deadline='$deadline',item='$item',price='$price',product='$product',content='$content' where id='$id'"; //echo $sql; mysql_query($sql,$conn); print "<mce:script type="text/javascript"><!-- location.href='c_infolist.php'; // --></mce:script>";//*/ }?> <form id="form1" name="form1" method="post" action="?action=edit&id=<?php echo $rs['id'];?>" onSubmit="return checkadd()"> </form>
删除代码
<a href="?action=del&id=<? echo $rs['id'];?>" onclick="return confirm('确定删除?')">删除</a> <? $action=$_GET['action']; switch($action){ //删除记录 case"del"; $id=$_GET['id']; $sql="delete from crm_info where id='$id'"; mysql_query($sql,$conn); print "<mce:script type="text/javascript"><!-- location.href='c_infolist.php'; // --></mce:script>"; break; } ?>
相关文章推荐
- PHP插入数据库代码,编辑,删除
- PHP插入数据库代码,编辑,删除
- PHP获取数据库表中的数据插入新的表再原删除数据方法
- PHP 获取要删除数据库表中的数据插入新的表再原删除数据
- 在PHP代码中取得当前日期时间再插入数据库
- php 将文本区域空格、换行转换成HTML代码后插入数据库的方法
- PHP接收json 并将接收数据插入数据库的实现代码
- 利用dbcp数据库连接池连接数据库,并利用dbtuils框架对数据库test中book表进行插入、删除、修改、查询的操作代码
- GridView自定义删除、编辑、全选删除代码(数据库应用membership)
- php读取txt文件组成SQL并插入数据库的代码(原创自Zjmainstay)
- php插入代码数据库
- eclipse中用jdbc连接数据库插入删除的代码
- php保存数据到数据库到后台显示删除编辑,到前台展示
- GridView的编辑,删除功能,用代码来实现GridView与数据库里表的绑定--来自百度知道
- 在PHP代码中取得当前日期时间再插入数据库
- php插入代码数据库
- 在可编辑表格EditorGrid中,我选择一行已输入的数据,点击删除按钮,该行数据将被删除,然后当我点击表单提交按钮时,已经被删除的那一行数据仍然被插入数据库中
- PHP接收json 并将接收数据插入数据库的实现代码
- 在可编辑表格EditorGrid中,我选择一行已输入的数据,点击删除按钮,该行数据将被删除,然后当我点击表单提交按钮时,已经被删除的那一行数据仍然被插入数据库中