Posted by: f4chru | August 1, 2008

Ry’s Paging Class ver0.5 for PHP and MySQL

Assalamu’alaikum

weew it was a long time since my last post….

Now we meet again, here I would like to promote one of my php class which is used for pagination….called ry’s PHP pagination v0.5

This class was created during the development of www.kantongmusik.com, you can said that it was accidentally created.

This is a open source code so if you find any bugs or error you free to fix it and please give a report to me or give me your fixed code (this is an agreement) :p.

For this immature version, this class only compatible with windows/linux OS, >PHP4, and MySQL database (soon will be compatible for SQLServer).

You can download the script here
http://www.geocities.com/urhcaf_xp/rypaging_class.zip

Features inside:
- This class give instant pagination navigation
- 2 navigation style google like, book like
- Easy to use
- Opensource
- Free

How to use

First of all you need to make sure that you connected to your database server. Since this class empower session as its core, you need to add session_start() in the beginning of your code

<?php
//required (fardu a’in)
session_start();
$conn=mysql_connect("host","username","password");
$select_db=mysql_select_db("newsportal",$conn);
include("rypaging_class.php"); // embed pagination class (consider the path)
?>
<table cellpadding="5">
<tr style="font-weight:bold;background-color:#CCCCCC;" align="center">
<td>Id</td>
<td>News Title</td>
</tr>
<?php
// define $pagination as class pagination
$pagination=new pagination;

// call variable needed for the pagination
// $var will be an array with $var[0] as item perpage, $var[1] as current page, and $var[2] as total page

$var=$pagination->generatevariable(5,"select news_id from news");

// here are your SQL syntax string to get the data from database
$myprojectString="select news_id,news_title from news limit ".$var[0].",5";
$myprojectQuery=mysql_query($myprojectString);
$no=1;
while ($myprojectFetch=mysql_fetch_array($myprojectQuery)){
echo "
<tr>
<td>",$myprojectFetch['content_id'],"</td>
<td>",$myprojectFetch['content_title'],"</td>
</tr>
";
$no++;
}
?>
<tr>
<td align="center" colspan="2">
<!-- START PAGINATION -->
<?php
// render the pagination
$pagination->rendernavbook($var[1],$var[2]);
?>
<!-- END PAGINATION -->
</td>
</tr>
</table>

here you can render two navigation style
- google like: you can use $pagination->rendernavgo($var[1],$var[2]); at render the pagination section
- book like: you can use $pagination->rendernavbook($var[1],$var[2]); at render the pagination section

Enjoy…!!!!

Wassalam


Responses

  1. cool stuff, i’ll try this out, some time, keep writing bro

  2. ahaha it’s just a newbie’s stuff….

  3. just visiting hehehe… nice blog content

  4. thanks a lot….this blog is just a simple note from me he he he……


Leave a response

Your response:

Categories