php一个更新记录的代码

| |
[不指定 2006/06/14 18:14 | by Else ]
<?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());
}
?>


作者:Else 's Blog
地址:http://www.aixq.com/post/273/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“php一个更新记录的代码”相关内容
  • 中查看更多“php一个更新记录的代码”相关内容
  • 中查看更多“php一个更新记录的代码”相关内容
  • 中查看更多“php一个更新记录的代码”相关内容
  • 中查看更多“php一个更新记录的代码”相关内容
  • 中查看更多“php一个更新记录的代码”相关内容
  • Tags: , ,
    代码 程序 编程 | 评论(0) | 引用(0) | 阅读(2340)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]