PHP Simple Paging Program

Source: Internet
Author: User

function Newlista ($action) {
$sql = "SELECT * from Gx_news";
if ($action = = ' Today ') {$sql. = "Where DateDiff (New_time,". Date ("y-m-d"). ") <=0 "; }
$result =mysql_query ($sql) or Die (' Fail1 '. mysql_error ());
$rs =mysql_fetch_array ($result);
$rdcount =mysql_num_rows ($result);
if ($rdcount) {
$pagesize = 15;
$pagecount = ($rdcount% $pagesize)? (int) ($rdcount/$pagesize) + 1: $rdcount/$pagesize;//Total Statistics page
$page =isset ($_get[' page ')? $_get[' page ']:1;//get the current page
$start = ($page >=1 && $page <= $pagecount)? $start = $pagesize * ($page-1): $start =1;//to get the super record
$start = $start;
$sql = $sql. "ORDER BY id desc limit $start, $pagesize";
$BG = 1;

$resulte =mysql_query ($sql) or Die (' fail '. mysql_error ());
$result =mysql_query ($sql) or Die (Mysql_error ());
while ($rs =mysql_fetch_array ($result)) {
if ($bg% 2!=0) {

$style = "Class=color";

}else{

$style = "";

}

echo "<li $style ><a href= ' newscenter.php?id=". $rs [0]. "' Target=_blank > '. $rs [' New_title ']." </a><span>[". $rs [' New_time ']."] </span></li> ";
$BG + +;
}
Echo ' </ul><div class=navigation> ';
echo "". PageList ($page, $pagecount, $rdcount, '? page= ', $pagesize). " </div> ";
}else{
Echo ' temporarily has no information! '
}

}

I original reproduced annotated www.111cn.net/phper/php.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.