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
相关文档:
因为工作需要,数据库使用的MS SQL Server2005,而默认的排序规则是SQL_Latin1_General_CP1_CI_AS。创建了一个表,因为需要存储中文信息,Address字段的类型是nvarchar(255)。
此时使用php来连接sql server,页面的编码和文件的编码都是UTF-8,查询此Address字段,显示在页面上是???之类的。怎么解决?
使用
iconv('iso- ......
1.php中的__FILE__常量返回文件的完整路径和文件名.
2.dirname(__FILE___) 函数返回的是脚本所在在的路径。
比如文件 b.php 包含如下内容:
<?php
$basedir = dirname(__FILE__);
?>
如果b.php被其他目录里的a.php文件require 或者 include 去引用的话。
变量?$basedir 的内容还是b.php所在的那个文件夹 ......
原文转自 :http://home.phpchina.com/space.php?uid=49655&do=blog&id=182488
一. 必备知识
1.wsdl(web服务标记语言)
WSDL(网络服务描述语言,Web Services Description Language)是一门基于 XML
的语言,用于描述 Web Services 以及如何对它们进行访问。
......
前言:
多语言网站开发,重点的还是在解决语言之间的问题。
那如何解决这个问题呢?大概就分三步走:
1.页面多语言
2.数据库多语言
3.用户访问语言统一
1.页面多语言
需要考虑的问题:
A.用户登陆时候,自动识别字符,调用不同的语言包?
B.用户切换不同语言时候,调用不同的语 ......
PHP提供了大量的内置函数,使开发人员在时间的处理上游刃有余,大大提高了工作效率。我们今天就为学员介绍一些常见的PHP日期和时间函数以及日期和时间的处理。
9.1 常用的日期和时间处理函数
表9-1:常用的日期和时间处理函数
函 数
说 明
checkdate
验证时间函数,判断时间是否有效,有效返回true,否则返回fa ......