Location: PHPKode > scripts > Paging for MySQL > paging-for-mysql/sample3.txt
<?
// see online: http://kentung.f2o.org/scripts/paging/sample3.php
include("./form.html");

require("paging_class.php");

$paging=new paging(10,5, "<img src=\"images/prev.gif\" alt=\"prev\">", "<img src=\"images/next.gif\" alt=\"next\">", "(%%number%%)");
$paging->db("localhost","username","password","dbname");

$qw=explode_keyword($_GET[keyword]);

$paging->query("select * from paging where $qw order by MY_FIELD desc");

$page=$paging->print_info();

if (!empty($page["keyword"]))
	echo "Keyword : <b>$page[keyword]</b><br>\n";

if (empty($page["total"])) {
	echo "<u>Not Found</u>\n";
} else {
	echo "Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<br>\n";
}

echo"	<table border=\"1\" cellspacing=\"0\" width=\"100%\" cellpadding=\"2\">\n";

while ($result=$paging->result_assoc())
{
	$color=$paging->print_color("yellow","#FFCCCC")
	?>
		<tr>
		    <td width="3%" bgcolor="<?=$color?>"><?=$paging->print_no()?></td>
		    <td width="98%" bgcolor="<?=$color?>"><?=$result[MY_FIELD]?></td>
		</tr>
	<?
}

echo"	</table>\n";

echo $paging->print_link();

//FUNCTION
function explode_keyword($q)
{
		//trim
		$q=trim($q);
		$q=preg_replace("/[\s]+/"," ",$q);

			$mode="AND";
			$q2=explode(" ",$q);
			for ($i=0;$i<count($q2);$i++) {
				$condition=$condition."MY_FIELD"." like '%".$q2["$i"]."%' ".$mode." ";
			}
			$condition=substr($condition,0,-4);
			return $condition;
}
?>
Return current item: Paging for MySQL