<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE artcat SET catname=%s, list=%s, pid=%s, `view`=%s, catcon=%s, menu=%s, ruby=%s WHERE id=%s",
GetSQLValueString($_POST['catname'], "text"),
GetSQLValueString($_POST['list'], "int"),
GetSQLValueString($_POST['pid'], "int"),
GetSQLValueString(isset($_POST['view']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['catcon'], "text"),
GetSQLValueString(isset($_POST['menu']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['ruby']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
}
?>
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE artcat SET catname=%s, list=%s, pid=%s, `view`=%s, catcon=%s, menu=%s, ruby=%s WHERE id=%s",
GetSQLValueString($_POST['catname'], "text"),
GetSQLValueString($_POST['list'], "int"),
GetSQLValueString($_POST['pid'], "int"),
GetSQLValueString(isset($_POST['view']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['catcon'], "text"),
GetSQLValueString(isset($_POST['menu']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['ruby']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
}
?>
作者:Else 's Blog
地址:http://www.aixq.com/post/273/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
中查看更多“php一个更新记录的代码”相关内容
中查看更多“php一个更新记录的代码”相关内容
中查看更多“php一个更新记录的代码”相关内容
中查看更多“php一个更新记录的代码”相关内容
中查看更多“php一个更新记录的代码”相关内容
中查看更多“php一个更新记录的代码”相关内容相关日志
把php优化成html的.htaccess的方法
修改原来的类,达到可以执行存储过程
asp導出excel的文件,附加php的方法
php列出目录中的所有文件
10 件(也许)你不了解 PHP 的事情
把php优化成html的.htaccess的方法
修改原来的类,达到可以执行存储过程
asp導出excel的文件,附加php的方法
php列出目录中的所有文件
10 件(也许)你不了解 PHP 的事情
mysql的函数库
php字符串函数


2006/06/14 18:14 | by 
