Jump to content

Help me with paginate () PAGE NUMBER


smartguyin

Recommended Posts

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..

[code]<?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";

?>[/code]

Please Help Me this ..... I am very new to this paging thing.... Please Help Me.....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.