PHP jquery Implementation News Tag classification and no refresh paging _php tutorial

Source: Internet
Author: User
Now the application of jquery is more and more widespread, in many Web site's news section has realized the label classification + has no refresh page effect.
Also try to write one yourself, as follows (the style can be the same as the user needs to go to the whole):

The implementation process is described in detail next:

I have always been to see the idea of a solution to recruit, here need to apply to 3 things--Tab effect plug-ins and paging plug-ins, jquery Getjson request.

So I used the Jquery-ui plugin, Jquery-page plugin, now provides download address:

Jquery_all.rar
It contains 3 JS script files and 2 style sheets:
Jquery-1.3.2.min.js
Jquery.pager.js
Jquery-ui-1.7.2.custom.min.js
Jquery-ui-1.7.2.custom.css

Page.css
The HTML page code looks like this:
Copy the Code code as follows:



php + jquery UI + jquery Pager











    • 2009

    • 2008

    • 2007


















Page made a Getjson request for ajax4.php,ajax5.php,ajax6.php three pages,
These 3 page code are similar, is nothing more than the classification of the year, I do not do code optimization here,
The actual can be placed in the same page to finish processing, the request address is accompanied by a parameter on the line.
The ajax.php code is as follows:
Copy CodeThe code is as follows:
Header ("Content-type:text/html;charset:utf-8");
$db = @ mysql_connect ("Server host Address", "Database Account", "Database Password");
mysql_select_db ("database name");
$rs =mysql_query ("Set names UTF8");
If the pager parameter is passed
if (Isset ($_get[' pager ')) && isset ($_get[' count '))
{
echo Getpager ($_get[' count '],$_get[' pager ');
}
Else
{
echo "No parameters passed in!";
}

function Getpager ($count, $pager)
{
$begin = start time;
$end = end time;
$rs =mysql_query ("SELECT * from data table WHERE (pubdate between $begin and $end) ORDER by pubdate DESC limit". $pager-1) * $count. ",". $count);
while ($r =mysql_fetch_assoc ($RS))
{
$temp []= $r;
}
$html _string= "






"; foreach ($temp as $k + $v) {//assuming URL word Keweiking address, title is news headline, pubdate is published $html _string.= " "; } $html _string.= "
". $v [' title ']." ". $v [" pubdate "]."
";
This is the number of news reads, not recommended to read too much
$num = 40;
The total number of pages in the news is rounded
$num _string=ceil ($num/$count);
This returns the JSON-formatted data in the form of a key-value pair, 0 for the total number of news pages, and 1 for the stitched HTML News page.
$arr =array ("0" = $num _string, "1" = = $html _string);
$jarr =json_encode ($arr);
Echo $jarr;
}
?>

Jquery_all.rar

http://www.bkjia.com/PHPjc/320905.html www.bkjia.com true http://www.bkjia.com/PHPjc/320905.html techarticle now the application of jquery is more and more widespread, in many Web site's news section has realized the label classification + has no refresh page effect. Also try to write one yourself, as follows (style ...

  • 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.