Membuat Pagination dengan AJAX dan PHP

Posted on Updated on


Mungkin jika kita Membuat paging dengan PHP itu sih uda biasa.. gimana klo di tambahin AJAX biar tambah keren.. ada animasinya, Kebetulan ane  nemuin cara membuat paging dengan Ajax JQuery . Tutorial ini untuk membuat pagination dengan beberapa efek jquery sehingga paging di website akan terlihat lebih menarik.Berikut contoh script yang udah Untuk Membuat Paging dengan AJAX, JQUERY, dan PHP

Pertama buat contoh database dulu..

CREATE TABLE IF NOT EXISTS `records` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `message` text NOT NULL,
  `image` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `records`
--

INSERT INTO `records` (`id`, `message`, `image`) VALUES
(1, 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since the 1500s,', '1.png'),
(2, 'There are many variations of passages of Lorem Ipsum available,  but the majority have suffered alteration in some form, by injected humour,  or randomised words which don''t look even slightly believable.', '2.png');

Lalu buat script JQuery Buat effect animasi nya..

$(document).ready(function(){

    function showLoader(){

        $('.search-background').fadeIn(200);
    }

    function hideLoader(){

        $('.search-background').fadeOut(200);
    };

    $("#paging_button li").click(function(){

        showLoader();

        $("#paging_button li").css({'background-color' : ''});
        $(this).css({'background-color' : '#006699'});

        $("#content").load("data.php?page=" + this.id, hideLoader);

        return false;
    });

    $("#1").css({'background-color' : '#006699'});
    showLoader();
    $("#content").load("data.php?page=1", hideLoader);

});

erakhir Code HTMLnya.

<div>

<div id="container">

<div class="search-background">
            <label><img src="loader.gif" alt="" /></label></div>
</div>

<div id="paging_button">

<ul>
        '.$i.'

';
        }?&gt;
</ul>
</div>
</div> download Source di sini 

One thought on “Membuat Pagination dengan AJAX dan PHP

    bangid said:
    January 5, 2014 at 3:40 pm

    link downloadnya ko gak bisa gan??

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s