<?php
//CONNECTION TO DATABASE!
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="accounts"; // Database name
$tbl_name="login"; // Table name
$tbl1_name="details"; // Table1 name
$con=mysql_connect("$host","$username","$password");
mysql_select_db("$db_name",$con);
$show_all=$_POST['rg01']; // Show All
//echo $show_all;
if($show_all!="")
{
$sql="SELECT * FROM $tbl1_name WHERE sex='$show_all'";
$result=mysql_query($sql);
}
else
{
echo "SELECT EITHER BRIDE or GROOM";
}
//**EDIT TO YOUR TABLE NAME, ECT.
$t = mysql_query("SELECT * FROM $tbl1_name WHERE `cat` = '".addslashes($_GET['cat'])."'");
if(!$t) die(mysql_error());
$a = mysql_fetch_object($t);
$total_items = mysql_num_rows($t);
$limit = $_GET['limit'];
$type = $_GET['type'];
$page = $_GET['page'];
//set default if: $limit is empty, non numerical, less than 10, greater than 50
if((!$limit) || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) {
$limit = 5; //default
}
//set default if: $page is empty, non numerical, less than zero, greater than total available
if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) {
$page = 1; //default
}
//calcuate total pages
$total_pages = ceil($total_items / $limit);
$set_limit = $page * $limit - ($limit);
//query: **EDIT TO YOUR TABLE NAME, ECT.
$q = mysql_query("SELECT * FROM tbl1_name WHERE `cat` = '".addslashes($_GET['cat'])."' LIMIT $set_limit, $limit");
if(!$q) die(mysql_error());
$err = mysql_num_rows($q);
if($err == 0) die("No matches met your criteria.");
//Results per page: **EDIT LINK PATH**
echo("
<a href=http://localhost/wamp/www/new.php?cat=$cat&limit=5&page=1>5</a> |");
//show data matching query:
while($code = mysql_fetch_object($q)) {
echo("item: ".$code->title."<BR>");
}
$cat = urlencode($cat); //makes browser friendly
//prev. page: **EDIT LINK PATH**
$prev_page = $page - 1;
if($prev_page >= 1) {
echo("<b><<</b> <a href=http://localhost/wamp/www/new.php?cat=$cat&limit=$limit&page=$prev_page><b>Prev.</b></a>");
}
//Display middle pages: **EDIT LINK PATH**
for($a = 1; $a <= $total_pages; $a++)
{
if($a == $page) {
echo("<b> $a</b> | "); //no link
} else {
echo(" <a href=http://localhost/wamp/www/new.php?cat=$cat&limit=$limit&page=$a> $a </a> | ");
}
}
//next page: **EDIT THIS LINK PATH**
$next_page = $page + 1;
if($next_page <= $total_pages) {
echo("<a href=http://localhost/wamp/www/new.php?cat=$cat&limit=$limit&page=$next_page><b>Next</b></a> > >");
}
?>
i got this code online, when i run it for my page getting Error Notice like this...
Notice: Undefined index: cat in C:\wamp\www\28_09_pm_new\new.php on line 102
Unknown column 'cat' in 'where clause'
this is due to query at line no 30 & 54...
someone help me...
Thankx in Advance...