Jump to content


Photo

Help me with paginate () PAGE NUMBER


  • Please log in to reply
1 reply to this topic

#1 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 28 July 2006 - 04:44 PM

As the query gives lots of results i want to get the page numbers on the screen soo that limiteed number of results can be displayed and others on other pages... systematically

I have built one code I know some thing is wrong in this either the code is not properly arranged or the function paginate() not working properly... Below is the code i prepared... Please Correct Me.... Where am i going wrong..

<?php
session_start();
include "conn.inc.php";
include "header.php";
/////////////

if (isset ($_POST['submit']) && $_POST['submit'] == "Search") {

$currpage = $_SERVER['PHP_SELF'];
global $limit;

if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
if ($limit == "") $limit = 5;
$start = ($page - 1)*$limit;

function paginate($limit=10) {
global $admin;

$sql = "SELECT FOUND_ROWS();";
$result = mysql_query($sql)
or die(mysql_error());
$row = mysql_fetch_array($result);
$numrows = $row[0];
$pagelinks = "<div class=\"pagelinks\">";
if($numrows > $limit) {
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}

} else {
$pagelinks .= "<span class='pageprevdead'>&lt;PREV</span>&nbsp;&nbsp;";
$pagelinks .= "<span class='pageprevdead'>&lt;PREV</span>&nbsp;&nbsp;";
}
}

if($page == 1) {
$pagelinks .= "<span class='pageprevdead'>&lt; PREV</span>";
} else {
$pageprev = $page - 1;
$pagelinks .= "<a class=\"pageprevlink\" href'".$currpage."&page=".$pageprev."'>&lt; PREV</a>";
}

global $pagelinks;


$query = "SELECT SQL_CALC_FOUND_ROWS * FROM fl WHERE fl_city = '".$_POST['place']."' AND fl_sellbuy = '1' ORDER BY fl_date DESC LIMIT $start,$limit";

$results = mysql_query($query)
or die(mysql_error());
$pagelinks = paginate($limit);

echo "<center><h2>Search results for Property Type Flat or Gala</h2></center><p></p>";

while ($row = mysql_fetch_assoc($results)) {
echo "<table border=\"0\" class='data'>\n";
echo "<tr valign='top'>\n";

echo "<td width='190'><p><b>Property Type</b>:- ".$row['fl_flatgala']."<br>
      <b>Property posted by</b> ".$row['fl_userid']."<br><br>
	<font size='1'><b>Date/Time of Post</b>:- ".$row['fl_date']."</font></p>
	<i><p><font size='2'><a href='flatgaladetails.php?id=".$row['fl_id']."'>Click here for more property details</a></font></p></i></td>
    <td width='203'> 
      <p><b>Property ID</b>:-".$row['fl_id']."<br><b>Property Title</b> :- ".$row['fl_title']."</p>
      <p><b>Description</b>:- ".$row['fl_desc']."</p>
    </td>
    <td width='182'> 
      <p><b>Area</b>:- ".$row['fl_area']."</p>
      <p><b>Price</b>:- ".$row['fl_price']."</p>
      <p><b>Property Address</b>:-<br>
        ".$row['fl_address']."</p>
    </td>
    <td width='128'><b><i><a href='contact.php?id=".$row['fl_id']."&type=buy flat/gala'>Click here to contact for buying this propety</a><b></i></td>";

echo "</tr>\n";
echo "</table><hr>\n";
}
////

echo $pagelinks;

include "footer.php";

?>

Please Help Me this ..... I am very new to this paging thing.... Please Help Me.....
One of my php project >> http://www.mumbaipropertysite.com

#2 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 29 July 2006 - 04:40 PM

PLEASE HELP ME !!!
One of my php project >> http://www.mumbaipropertysite.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users