一个PHP+MSSQL分页的例子
一个PHP+MSSQL分页的例子,一个PHP+MSSQL分页的例子
require "config.php";
dl("extensions/php_mssql70.dll");
if (!isset($page)) { $page=1; }
if ($page<=0) { $page=1; }
$db=mssql_connect($local,$user,$pass);
mssql_select_db($name,$db);
$query=mssql_query("select count(*) as date from news",$db);
$query=mssql_fetch_array($query);
$pages=ceil($query[0]/$userperpage);
if ($page$pages) { $page=$pages;}
if ($query[0]<$userperpage) { $userperpage=$query[0]; }
$dangqian=($page-1)*$userperpage;
echo "<titleNews</title";
echo "<style type=text/cssn";
echo "<!--n";
echo "A{text-decoration:none}n";
echo "A:hover {color:blue;; text-decoration: underline}n";
echo "td { font-size: 9pt}n";
echo "--</stylen";
echo "<div align=center<centern";
echo "<table border=0 width=100% cellspacing=0 cellpadding=0 height=19n";
echo "<tr";
echo " <td width=52% colspan=5<img src="http://img.jcwcn.com/attachment/portal/jcwcj/2005-12/10/05121010162513712.gif" width=100%</td</trn";
echo "<tr";
echo " <td width=52% height=19 valign=bottom bgcolor=#B5C6B0<p align=center<fontn";
echo " color=#408080新闻标题</font</tdn";
echo " <td width=14% height=19 valign=bottom align=center bgcolor=#B5C6B0<fontn";
echo " color=#408080发表日期</font</tdn";
echo " <td width=19% height=19 valign=bottom align=center bgcolor=#B5C6B0<fontn";
echo " color=#408080发表部门</font</tdn";
echo " <td width=7% height=19 valign=bottom align=center bgcolor=#B5C6B0<fontn";
echo " color=#408080阅读</font</tdn";
echo " <td width=8% height=19 valign=bottom align=center bgcolor=#B5C6B0<fontn";
echo " color=#408080图像</font</tdn";
echo " </trn";
echo "</tablen";
echo "</center</divn";
echo "<div align=center<centern";
echo "<table border=0 width=100% cellspacing=0 cellpadding=0 height=19n";
$db=mssql_connect($local,$user,$pass);
mssql_select_db($name,$db);
$query=mssql_query("select * from news order by date desc",$db);
$roro=mssql_num_rows($query);
if ($roro==0) {
echo "<br<br<p align="center"<font color="#FF0000" size="2"<marquee behavior="alternate" border="0" width="300" height="16" scrolldelay="70"目前数据库中无任何记录!</marquee</font</p";
exit;
}
mssql_data_seek($query,$dangqian);
$i=0;
while ($arr=ms