——此文章摘自《完全手册PHP网络开发详解》定价
¥
特价
¥
详细>>http://track
linktech
cn/?m_id=dangdang&a_id=A
&l=
&l_type
=
width=
height=
border=
nosave>
文章类别管理页面与文章管理页面类似不同的是更新的表为types具体代码如下所示
<?php require_once(Connections/connphp); ?>
<?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;
}
//插入操作
if ((isset($_POST[MM_insert])) && ($_POST[MM_insert] == form))
{
// $insertSQL = sprintf(INSERT INTO types (type_name) VALUES (%s)
// GetSQLValueString($_POST[type_name] text));
$insertSQL = sprintf(INSERT INTO types (type_id type_name last_upt_id)
SELECT MAX(type_id)+ %s %s FROM types
GetSQLValueString($_POST[type_name] text)
GetSQLValueString($_SESSION[MM_Username] text));
mysql_select_db($database_conn $conn);
$Result = mysql_query($insertSQL $conn) or die(mysql_error());
echo <script>alert(新类别创建成功!);</script>;
}
//更新操作
if ((isset($_POST[MM_update])) && ($_POST[MM_update] == form))
{
//验证新type_id的有效性
$validateSQL = sprintf(SELECT type_name FROM types WHERE type_id=%s
GetSQLValueString($_POST[new_type_id] int));
mysql_select_db($database_conn $conn);
$rs_validate_merge = mysql_query($validateSQL $conn) or die(mysql_error());
$row_rs_validate_merge = mysql_fetch_assoc($rs_validate_merge);
right>[] [http://developcsaicn/web/htm>] [http://developcsaicn/web/htm>] [http://developcsaicn/web/htm>] [http://developcsaicn/web/htm>]