开发者

How to show 5 records in 5 different <DIV > tags using jquery PHP Mysql with Next /prev button

I have html page whicha has 5 Div tags in disable mode. what I want is

Imagine I have 200 records in mysql database table

  1. Using Jquery I want to call PHP Mysql data (only 5 records at a time)
  2. When user clicks on Next button PHP page will get called Limit 6, 10 and so on
  3. if user clicks 开发者_JAVA百科on Prev button then previous 5 records

following example is good enough bit it has pagination with numbers i want Next/Prev buttons.

http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html


For starters in pagination.php

Change this:

//Pagination Numbers
for($i=1; $i<=$pages; $i++)
{
echo '<li id="'.$i.'">'.$i.'</li>';
}

To this:

// Show 'next' link
echo '<li id="'.2.'">Next page</li>';

To create you first 'next'-link.

Then add some jQuery code to

  • Add a prev button when you click to the next page(only if currentpage = 1) and remove it again on page 1
  • Include your result's count as a js-var, so you will know when the last page is reached to remove the next button.
  • On each load, change page number's +/- 1

Your php stays the same since you always send a page id to use in your query.

Have you tried writing this yourself? If so, where did you encounter problems?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜