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

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

2013-11-15 12:40:10  來源: PHP編程 
    ——此文章摘自《完全手冊PHP網絡開發詳解》定價 特價 詳細>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

      $totalRows_rs_upt_type = mysql_num_rows($rs_validate_merge);
     
    if(($totalRows_rs_upt_type>) && ($row_rs_validate_merge[type_name] ==
    $_POST[type_name]))
     {
        //更新articles並且刪除types
        $updateSQL = sprintf(UPDATE articles SET type_id=%s last_upt_id=%s WHERE
    type_id=%s
                           GetSQLValueString($_POST[new_type_id] int)
                           GetSQLValueString($_SESSION[MM_Username] text)
                           GetSQLValueString($_POST[type_id] int));
        mysql_select_db($database_conn $conn);
        $Result = mysql_query($updateSQL $conn) or die(mysql_error());
        //刪除
        $deleteSQL = sprintf(DELETE FROM types WHERE type_id=%s
                           GetSQLValueString($_POST[type_id] int));
        mysql_select_db($database_conn $conn);
        $Result = mysql_query($deleteSQL $conn) or die(mysql_error());
        echo <script>alert(類別更新成功!);</script>;
      }
      elseif($totalRows_rs_upt_type>) {
        echo <script>alert(\類別更新失敗!原因可能是\\n類別編號與現有的類別編號重復
    \\n新類別名稱與現有相同編號的類別名稱不一致\);</script>;
      }
    else
      {
        //更新types
        $updateSQL = sprintf(UPDATE types SET type_id=%s type_name=%s WHERE
    type_id=%s
                           GetSQLValueString($_POST[new_type_id] int)
                           GetSQLValueString($_POST[type_name] text)
                           GetSQLValueString($_POST[type_id] int));
        mysql_select_db($database_conn $conn);
        $Result = mysql_query($updateSQL $conn) or die(mysql_error());
        //同時更新articles表中的相應記錄
        $updateSQL = sprintf(UPDATE articles SET type_id=%s WHERE type_id=%s
                           GetSQLValueString($_POST[new_type_id] int)
                           GetSQLValueString($_POST[type_id] int));
        mysql_select_db($database_conn $conn);
        $Result = mysql_query($updateSQL $conn) or die(mysql_error());
     
        echo <script>alert(類別更新成功!);</script>;
      }
    }
    //刪除操作
    if (isset($_GET[MM_delete]))
    {
      $deleteSQL = sprintf(DELETE FROM types WHERE type_id=%s
                           GetSQLValueString($_GET[MM_delete] int));
      mysql_select_db($database_conn $conn);
      $Result = mysql_query($deleteSQL $conn) or die(mysql_error());

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/21379.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.