——此文章摘自《完全手册PHP网络开发详解》定价
¥
特价
¥
详细>>http://track
linktech
cn/?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>]