Jpaginate php mysql 分页应用实例
JavaScript Code
- <script>
- $(document).ready(function(){
- $("#demo").paginate({
- count:<?php echo $page;?>,
- start:1,
- display:10,
- border:true,
- border_color:'#BEF8B8',
- text_color:'#79B5E3',
- background_color:'#E3F2E1',
- border_hover_color:'#68BA64',
- text_hover_color:'#2573AF',
- background_hover_color:'#CAE6C6',
- images:false,
- mouse:'press',
- onChange:function(page){
- $("#pagetxt").load("page.php?page="+page);
- }
- })
- })
- </script>
XML/HTML Code
- <div class="demo">
- <div id="pagetxt">
- <?php
- $result = mysql_query("select * from `content` order by id desc limit 0,10");
- while($row = mysql_fetch_array($result)){
- echo "<p>$row[id]<a>".$row[name]."</a></p>";
- }
- ?>
- </div>
- <div id="demo"></div>
- </div>
page.php
PHP Code
- <?php
- include("conn.php");
- $result = mysql_query("select count(*) as c from `content`");
- $row = mysql_fetch_array($result);
- $total = $row['c'];
- $pagesize = 10;
- $page = ceil($total/$pagesize);
- $start = ($_GET['page'] - 1)*$pagesize;
- if(isset($_GET['page'])){
- $result = mysql_query("select * from `content` order by id desc limit $start,$pagesize");
- while($row = mysql_fetch_array($result)){
- echo "<p>$row[id]<a>
- ".$row[name]."</a></p>";
- }
- }
- ?>
原文地址:http://www.freejs.net/article_fenye_113.html