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

PHP網絡開發詳解:頁面代碼設計[3]

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

    PHP代碼如下所示
    <! 首頁文件indexphp >
    <?php require_once(Connections/connphp); ?>
    <?php
    //分頁的計算
    $maxRows_rs_articles = ;                      //每頁顯示記錄數
    $pageNum_rs_articles = ;                       //初始化頁碼編號
    if (isset($_GET[pageNum_rs_articles]))        //獲取當前頁碼
    {
      $pageNum_rs_articles = $_GET[pageNum_rs_articles];
    }
    $startRow_rs_articles = $pageNum_rs_articles * $maxRows_rs_articles;                                                        //計算起始記錄數
    //讀取文章信息
    mysql_select_db($database_conn $conn);
    $query_rs_articles = SELECT * FROM articles WHERE checked_indc= ORDER BY
    last_upt_time DESC;
    $query_limit_rs_articles = sprintf(%s LIMIT %d %d $query_rs_articles
    $startRow_rs_articles $maxRows_rs_articles);
    $rs_articles = mysql_query($query_limit_rs_articles $conn) or die(mysql_error());
    $row_rs_articles = mysql_fetch_assoc($rs_articles);
    //設定分頁頁碼
    if (isset($_GET[totalRows_rs_articles])) //如果參數中存在總記錄數則獲取
    {
      $totalRows_rs_articles = $_GET[totalRows_rs_articles];
    }
    else                                            //否則執行SQL語句計算
    {
      $all_rs_articles = mysql_query($query_rs_articles);
      $totalRows_rs_articles = mysql_num_rows($all_rs_articles);
    }
    $totalPages_rs_articles = ceil($totalRows_rs_articles/$maxRows_rs_ articles);                                                 //計算總頁數
    //讀取文章類別信息
    mysql_select_db($database_conn $conn);
    $query_rs_types = SELECT * FROM types ORDER BY type_id ASC;
    $rs_types = mysql_query($query_rs_types $conn) or die(mysql_error());
    $row_rs_types = mysql_fetch_assoc($rs_types);
    $totalRows_rs_types = mysql_num_rows($rs_types);
    //讀取網站配置信息
    mysql_select_db($database_conn $conn);
    $query_rs_config = SELECT * FROM config templates WHERE configtemplate_
    id=templatestemplate_id;
    $rs_config = mysql_query($query_rs_config $conn) or die(mysql_error());
    $row_rs_config = mysql_fetch_assoc($rs_config);
    $totalRows_rs_config = mysql_num_rows($rs_config);
    //驗證用戶權限
    session_start();
    $loginFormAction = $_SERVER[PHP_SELF];
    if (isset($accesscheck))                        //檢查是否已經登錄
    {
      $GLOBALS[PrevUrl] = $accesscheck;
      session_register(PrevUrl);
    }

right>[http://developcsaicn/web/htm>]  [http://developcsaicn/web/htm>]  []  [http://developcsaicn/web/htm>]  


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