易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP插入数据库代码,编辑,删除

插入代码
 <?
$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,$co


相关文档:

PHP查询显示SqlServer中的中文

因为工作需要,数据库使用的MS SQL Server2005,而默认的排序规则是SQL_Latin1_General_CP1_CI_AS。创建了一个表,因为需要存储中文信息,Address字段的类型是nvarchar(255)。
此时使用php来连接sql server,页面的编码和文件的编码都是UTF-8,查询此Address字段,显示在页面上是???之类的。怎么解决?
使用
iconv('iso- ......

PHP中基于MVC模式的小型项目总结

最近做了几个小型的项目,比较简单,只是需要细心,都可以完成,主要是对MVC模式的熟练应用,对WEB类开发还是很有帮助的。
刚开始的第一个小项目,用来练手,然后我全部是流程化的编程。代码也就400行左右。结果我的导师,觉得代码结构不清晰,不容易
维护,需要修改。需要我采用OO类的编程方式进行改写。我以前写PHP,几 ......

php中__FILE__常量用法简介

1.php中的__FILE__常量返回文件的完整路径和文件名.
2.dirname(__FILE___) 函数返回的是脚本所在在的路径。
比如文件 b.php 包含如下内容:
<?php
$basedir = dirname(__FILE__);
?>
如果b.php被其他目录里的a.php文件require 或者 include 去引用的话。
变量?$basedir 的内容还是b.php所在的那个文件夹 ......

php学习心得(适合php初学者)


来源: 发布时间:2009-09-18 发布人: 浏览:30人次  字体:[大 中 小]  
 【1】页面之间无法传递变量 get,post,session在最新的php版本中自动全局变量是关闭的,所以要从上一页面取得提交过来得变量要使用$_GET['foo'],$_POST['foo'],$_SESSION['foo']来得到
当然也可以修改自动全局变量为开(ph ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号