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
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.= "
| ". $v [' title ']." |
". $v [" pubdate "]." |
"; } $html _string.= "
";
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 ...