熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

PHP網絡開發詳解:文章類別管理頁面的實現[1]

2022-06-13   來源: PHP編程 
    ——此文章摘自《完全手冊PHP網絡開發詳解》定價 特價 詳細>>http://tracklinktechcn/?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>]  


From:http://tw.wingwit.com/Article/program/PHP/201311/21378.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.