使用ajax php mysql实现分页搜索

使用ajax php mysql实现分页搜索,php,jquery,mysql,ajax,search,Php,Jquery,Mysql,Ajax,Search,嘿,伙计们,我正在尝试使用ajax、php、mysql和jquery在网站中实现搜索功能。现在,当我转到列表页面时,我的应用程序工作正常(页面,其中包含站点上的项目列表)。但我在索引页上进行了搜索,搜索结果必须显示在列表页上。基本分页是使用php完成的,适用于来自菜单的链接,但搜索失败。(即,如果使用搜索查询从索引页重定向,则不起作用) 搜索文本框: <form name="homePageSearchForm" method="post" action="cities.p

嘿,伙计们,我正在尝试使用ajax、php、mysql和jquery在网站中实现搜索功能。现在,当我转到列表页面时,我的应用程序工作正常(页面,其中包含站点上的项目列表)。但我在索引页上进行了搜索,搜索结果必须显示在列表页上。基本分页是使用php完成的,适用于来自菜单的链接,但搜索失败。(即,如果使用搜索查询从索引页重定向,则不起作用)

搜索文本框:

        <form name="homePageSearchForm" method="post" action="cities.php" autocomplete="off">
                 <!--   <input type="hidden" value="e.g kolte patil life republic, wagholi pune" id="hiddenExData" name="hiddenExData">-->
                    <div style="padding-top:5px; line-height:20px; width:280px;" class="flt">
                    <div class="flt"><strong>Locality, City, Builder or Project name</strong><span style="color:#FF3300;">*</span><br>
                    <div class="flt"><input type="text" onBlur="if(this.value=='') this.value='e.g kolte patil life republic, wagholi pune';" onFocus="if(this.value=='e.g kolte patil life republic, wagholi pune') this.value='';" value="e.g kolte patil life republic, wagholi pune" name="SearchValue" id="searchId" title="Search" class="headerinput ac_input" autocomplete="off">
这将以HTML的形式返回响应,但我无法将其显示在列表(properties.php)页面上。此外,如果使用搜索值,分页也不起作用。

fetchCity.php包含搜索查询和返回数据的HTML

                   $searchValue= $_GET['searchVal'];
$buttonEle  = $_GET['buttonEle'];
$current_page=$_GET['cur_page'];

    $locCity = explode(" ",$searchValue);
    $localitySearch =   $locCity[0];
    $citySearch     =    $locCity[1];

        $query = "SELECT * from properties inner join cities on properties.city_id=cities.city_id inner join locality on properties.locality_id=locality.locality_id where (cities.city_name like '%".$citySearch."%' and locality.locality_name like '%".$localitySearch."%') and (property_price_min between '78 Lacs' and '80 Lacs') $pages->limit";
    //echo $query;
    exit;
    $result = mysql_query($query) or die(mysql_error());


?>


<div class="width710" id="displayProp">

     <?php 


/*print_r($getProperty);
foreach($result as $property)*/
while($row=mysql_fetch_assoc($result))
{
      ?>
            <div class="projectlisttiger">      
            <div class="proptigerhead">PropTiger Recommends</div>   
                <div class="spacer5">&nbsp;</div>
                <div class="listnewimg flt">
                    <a href="p-kolte-patil-cilantro-wagholi-pune.php">
                        <img src="admin/uploads/<?php echo ($row['property_cover_image']) ?>" width="186" height="125" border="0">
                        <img src="admin/uploads/Cilantra1/1cilantra-large.jpg" width="186" height="125" border="0">
                    </a>
                     <div class="newlistlaunch"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="65" height="65" border="0" src="images/projects/kolte-patil/cilantra/new_launch_blue.png"></a>
                     </div>                             
                </div>

                <div class="listright">
                    <div style="width:498px; height:42px;" class="flt">
                        <div class="list-logo flt">
                            <div class="buildborder"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="80" height="36" border="0" align="absmiddle" alt="Kolte Patil" src="admin/uploads/<?php echo $row['builder_logo']?>"></a>
                            </div>
                               <div class="tablistname"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><?php echo $row['property_name'] ?></a></div>
                        </div>   
                        <?php if ($row['property_price_min']!=0) { ?>      
                        <div class="listprice">
                            <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif"> <?php echo $row['property_price_min'] ?> Lacs - <?php echo $row['property_price_max'] ?> Lacs       
                        </div>
                        <?php } else { ?>
                        <div class="listprice">
                             <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif">Price on Request
                        </div>
                        <?php } ?>

                    </div>

                        <div class="spacer3">&nbsp;</div>        SPACER

                    <div class="listbox">
                        <a href="p-kolte-patil-cilantro-wagholi-pune.php"><strong>Address</strong>:<?php echo $row['locality_name'] ?>, <?php echo $row['city_name'] ?><br> <strong>Types</strong>: 2BHK &amp; 3BHK
                        <br><strong>Sizes:</strong> <?php echo $row['property_size_min'] ?> sqft - <?php echo $row['property_size_max'] ?> sqft </a>
                    </div>

                    <div style="margin-left:-3px;" class="flt">
                        <div style="width:110px;" class="flt"><a style="text-decoration:none;" href="p-kolte-patil-cilantro-wagholi-pune.php"><input type="button" value="View Details" class="detail_project"></a>
                        </div>     
                      <div style="width:110px;" class="flt"><input type="button" onClick="showEnqForm('2659','Cilantro'); return false;" value="Enquire Now" class="enquire_project"></div>
                    </div>
                           <div class="spacer">&nbsp;</div>        SPACER                                
                </div>
                <div class="spacer15">&nbsp;</div>                  SPACER
       </div>              

   <?php } 
   exit;

  // echo "<p class=\"paginate\">Page: $pages->current_page of $pages->num_pages</p>\n";
   ?>                         

        <div class="spacer15">&nbsp;</div>
       </div>
$searchValue=$\u GET['searchVal'];
$buttonEle=$_GET['buttonEle'];
$current\u page=$\u GET['cur\u page'];
$locCity=explode(“,$searchValue”);
$localitySearch=$locCity[0];
$citySearch=$locCity[1];
$query=“SELECT*from properties internal join cities on properties.city\u id=cities.city\u id internal join locality on properties.locality\u id其中(cities.city\u name类似“%”““%$citySearch.”和locality.locality\u name类似“%”“%$localitySearch.”%”)和(property\u price\u min介于“78 lac”和“80 lac”之间)$pages->limit”;
//echo$query;
出口
$result=mysql\u query($query)或die(mysql\u error());
?>
PropTiger建议
Lacs-Lacs
按要求定价
间隔棒
间隔棒
间隔棒
我想知道我的方法是否正确??如何在另一个页面上显示搜索结果,并且分页工作正常

作为参考,我将添加具有类似功能的参考网站的链接。

这是: 任何建议或帮助都将不胜感激。
分页类:

         class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $ipp_array;

function Paginator()
{
    $this->current_page = 1;
    $this->mid_range = 2;
    $this->ipp_array = array(2,4,6,8,10,'All');
    $this->items_per_page = (!empty($_GET['ipp'])) ? $_GET['ipp']:$this->default_ipp;
}

function paginate()
{
    if(!isset($this->default_ipp)) $this->default_ipp='10';
    if($_GET['ipp'] == 'All')
    {
        $this->num_pages = 1;
          //$this->items_per_page = $this->default_ipp;
    }
    else
    {
        if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
        $this->num_pages = ceil($this->items_total/$this->items_per_page);
    }
    $this->current_page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1 ; // must be numeric > 0
    $prev_page = $this->current_page-1;
    $next_page = $this->current_page+1;
    if($_GET)
    {
        $args = explode("&",$_SERVER['QUERY_STRING']);
        foreach($args as $arg)
        {
            $keyval = explode("=",$arg);
            if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
        }
    }

    if($_POST)
    {
        foreach($_POST as $key=>$val)
        {
            if($key != "page" And $key != "ipp") $this->querystring .= "&$key=$val";
        }
    }
    if($this->num_pages > 4)
    {
        $this->return = ($this->current_page > 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$prev_page&ipp=$this->items_per_page$this->querystring\">&laquo; Previous</a> ":"<span class=\"inactive\" href=\"#\">&laquo; Previous</span> ";

        $this->start_range = $this->current_page - floor($this->mid_range/2);
        $this->end_range = $this->current_page + floor($this->mid_range/2);

        if($this->start_range <= 0)
        {
            $this->end_range += abs($this->start_range)+1;
            $this->start_range = 1;
        }
        if($this->end_range > $this->num_pages)
        {
            $this->start_range -= $this->end_range-$this->num_pages;
            $this->end_range = $this->num_pages;
        }
        $this->range = range($this->start_range,$this->end_range);

        for($i=1;$i<=$this->num_pages;$i++)
        {
            if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
            // loop through all pages. if first, last, or in range, display
            if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
            {
                $this->return .= ($i == $this->current_page And $_GET['page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
            }
            if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
        }
        $this->return .= (($this->current_page < $this->num_pages And $this->items_total >= 10) And ($_GET['page'] != 'All') And $this->current_page > 0) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$next_page&ipp=$this->items_per_page$this->querystring\">Next &raquo;</a>\n":"<span class=\"inactive\" href=\"#\">&raquo; Next</span>\n";
        $this->return .= ($_GET['page'] == 'All') ? "<a class=\"current\" style=\"margin-left:10px\" href=\"#\">All</a> \n":"<a class=\"paginate\" style=\"margin-left:10px\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    else
    {
        for($i=1;$i<=$this->num_pages;$i++)
        {
            $this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
        }
        $this->return .= "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    $this->low = ($this->current_page <= 0) ? 0:($this->current_page-1) * $this->items_per_page;
    if($this->current_page <= 0) $this->items_per_page = 0;
    $this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_items_per_page()
{
    $items = '';
    if(!isset($_GET[ipp])) $this->items_per_page = $this->default_ipp;
    foreach($this->ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n";
    return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n";
}
function display_jump_menu()
{
    for($i=1;$i<=$this->num_pages;$i++)
    {
        $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n";
    }
    return "<span class=\"paginate\">Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n";
}
function display_pages()
{
    return $this->return;
}
类分页器{
var$items\u/页;
var$项目总计;
var$当前页面;
var$num_页面;
var$中档;
var$低;
var$限额;
var$收益;
var$default_ipp;
var$querystring;
var$ipp_数组;
函数Paginator()
{
$this->current_page=1;
$this->mid_range=2;
$this->ipp_数组=数组(2,4,6,8,10,'All');
$this->items\u per\u page=(!empty($\u GET['ipp'])?$\u GET['ipp']:$this->default\u ipp;
}
函数paginate()
{
如果(!isset($this->default_ipp))$this->default_ipp='10';
如果($_GET['ipp']=='All')
{
$this->num_pages=1;
//$this->items\u per\u page=$this->default\u ipp;
}
其他的
{
如果(!是数值($this->items\u per\u page)或$this->items\u per\u page items\u per\u page=$this->default\u ipp;
$this->num\u pages=ceil($this->items\u total/$this->items\u per\u page);
}
$this->current_page=(isset($_GET['page'])?(int)$_GET['page']:1;//必须是数值>0
$prev_page=$this->current_page-1;
$next_page=$this->current_page+1;
如果($\u GET)
{
$args=explode(&,$_服务器['QUERY_STRING']);
foreach($args作为$arg)
{
$keyval=explode(“=”,$arg);
如果($keyval[0]!=“page”和$keyval[0]!=“ipp”)$this->querystring.=“&”。$arg;
}
}
如果(美元邮政)
{
foreach($\发布为$key=>$val)
{
如果($key!=“page”和$key!=“ipp”)$this->querystring.=“&$key=$val”;
}
}
如果($this->num_pages>4)
{
$this->return=($this->current\u page>1和$this->items\u total>=10)?“”:“«;Previous”;
$this->start\u range=$this->current\u page-floor($this->mid\u range/2);
$this->end\u range=$this->current\u page+floor($this->mid\u range/2);
如果($this->start\u range end\u range+=abs($this->start\u range)+1;
$this->start_range=1;
}
如果($this->end\u range>$this->num\u pages)
{
$this->start\u range-=$this->end\u range-$this->num\u页面;
$this->end\u range=$this->num\u页面;
}
$this->range=range($this->start\u range,$this->end\u range);
对于($i=1;$inum_页面;$i++)
{
如果($this->range[0]>2和$i==$this->range[0])$this->return.=“…”;
//循环浏览所有页面。如果是第一页、最后一页或在范围内,则显示
如果($i==1或$i==$this->num\u页面或数组中($i,$this->range))
{
$this->return.=($i==$this->current_page和$_GET['page']!='All')?:“”;
}
如果($this->range[$this->mid_range-1]<$this->num_pages-1和$i==$this->range[$this->mid_range-1])$this->return.=“…”;
}
$this->return.=($this->current\u page<$this->num\u pages And$this->items\u total>=10)和($this->current\u page>0)和$this->current\u page>0)?“\n”:“»;Next\n”;
$this->return.=($\u GET['page']=='All')?“\n”:“\n”;
}
其他的
{
对于($i=1;$inum\u页)
             function handleHomePageSearch(buttonEle,e) {
             var criteria  = document.getElementById("searchCriteria").value;
            var searchVal = document.getElementById("searchId").value;
            xmlHttpSearchct=GetXmlHttpObject();
            var cur_page = document.getElementById("current_page").innerHTML;

            var url="fetchCity.php?&searchVal="+searchVal+"&buttonEle="+buttonEle+"&cur_page="+cur_page;
            alert(url);
            xmlHttpSearchct.open("GET",url,false);

            xmlHttpSearchct.send(null);

                           var Searchres=xmlHttpSearchct.responseText;
                       **//To get the response**
                        xmlhttp.onreadystatechange=function()
          {
              if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                                    document.getElementById('displayProp').innerHTML=Searchres;
                }
          }
                   $searchValue= $_GET['searchVal'];
$buttonEle  = $_GET['buttonEle'];
$current_page=$_GET['cur_page'];

    $locCity = explode(" ",$searchValue);
    $localitySearch =   $locCity[0];
    $citySearch     =    $locCity[1];

        $query = "SELECT * from properties inner join cities on properties.city_id=cities.city_id inner join locality on properties.locality_id=locality.locality_id where (cities.city_name like '%".$citySearch."%' and locality.locality_name like '%".$localitySearch."%') and (property_price_min between '78 Lacs' and '80 Lacs') $pages->limit";
    //echo $query;
    exit;
    $result = mysql_query($query) or die(mysql_error());


?>


<div class="width710" id="displayProp">

     <?php 


/*print_r($getProperty);
foreach($result as $property)*/
while($row=mysql_fetch_assoc($result))
{
      ?>
            <div class="projectlisttiger">      
            <div class="proptigerhead">PropTiger Recommends</div>   
                <div class="spacer5">&nbsp;</div>
                <div class="listnewimg flt">
                    <a href="p-kolte-patil-cilantro-wagholi-pune.php">
                        <img src="admin/uploads/<?php echo ($row['property_cover_image']) ?>" width="186" height="125" border="0">
                        <img src="admin/uploads/Cilantra1/1cilantra-large.jpg" width="186" height="125" border="0">
                    </a>
                     <div class="newlistlaunch"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="65" height="65" border="0" src="images/projects/kolte-patil/cilantra/new_launch_blue.png"></a>
                     </div>                             
                </div>

                <div class="listright">
                    <div style="width:498px; height:42px;" class="flt">
                        <div class="list-logo flt">
                            <div class="buildborder"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="80" height="36" border="0" align="absmiddle" alt="Kolte Patil" src="admin/uploads/<?php echo $row['builder_logo']?>"></a>
                            </div>
                               <div class="tablistname"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><?php echo $row['property_name'] ?></a></div>
                        </div>   
                        <?php if ($row['property_price_min']!=0) { ?>      
                        <div class="listprice">
                            <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif"> <?php echo $row['property_price_min'] ?> Lacs - <?php echo $row['property_price_max'] ?> Lacs       
                        </div>
                        <?php } else { ?>
                        <div class="listprice">
                             <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif">Price on Request
                        </div>
                        <?php } ?>

                    </div>

                        <div class="spacer3">&nbsp;</div>        SPACER

                    <div class="listbox">
                        <a href="p-kolte-patil-cilantro-wagholi-pune.php"><strong>Address</strong>:<?php echo $row['locality_name'] ?>, <?php echo $row['city_name'] ?><br> <strong>Types</strong>: 2BHK &amp; 3BHK
                        <br><strong>Sizes:</strong> <?php echo $row['property_size_min'] ?> sqft - <?php echo $row['property_size_max'] ?> sqft </a>
                    </div>

                    <div style="margin-left:-3px;" class="flt">
                        <div style="width:110px;" class="flt"><a style="text-decoration:none;" href="p-kolte-patil-cilantro-wagholi-pune.php"><input type="button" value="View Details" class="detail_project"></a>
                        </div>     
                      <div style="width:110px;" class="flt"><input type="button" onClick="showEnqForm('2659','Cilantro'); return false;" value="Enquire Now" class="enquire_project"></div>
                    </div>
                           <div class="spacer">&nbsp;</div>        SPACER                                
                </div>
                <div class="spacer15">&nbsp;</div>                  SPACER
       </div>              

   <?php } 
   exit;

  // echo "<p class=\"paginate\">Page: $pages->current_page of $pages->num_pages</p>\n";
   ?>                         

        <div class="spacer15">&nbsp;</div>
       </div>
         class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $ipp_array;

function Paginator()
{
    $this->current_page = 1;
    $this->mid_range = 2;
    $this->ipp_array = array(2,4,6,8,10,'All');
    $this->items_per_page = (!empty($_GET['ipp'])) ? $_GET['ipp']:$this->default_ipp;
}

function paginate()
{
    if(!isset($this->default_ipp)) $this->default_ipp='10';
    if($_GET['ipp'] == 'All')
    {
        $this->num_pages = 1;
          //$this->items_per_page = $this->default_ipp;
    }
    else
    {
        if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
        $this->num_pages = ceil($this->items_total/$this->items_per_page);
    }
    $this->current_page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1 ; // must be numeric > 0
    $prev_page = $this->current_page-1;
    $next_page = $this->current_page+1;
    if($_GET)
    {
        $args = explode("&",$_SERVER['QUERY_STRING']);
        foreach($args as $arg)
        {
            $keyval = explode("=",$arg);
            if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
        }
    }

    if($_POST)
    {
        foreach($_POST as $key=>$val)
        {
            if($key != "page" And $key != "ipp") $this->querystring .= "&$key=$val";
        }
    }
    if($this->num_pages > 4)
    {
        $this->return = ($this->current_page > 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$prev_page&ipp=$this->items_per_page$this->querystring\">&laquo; Previous</a> ":"<span class=\"inactive\" href=\"#\">&laquo; Previous</span> ";

        $this->start_range = $this->current_page - floor($this->mid_range/2);
        $this->end_range = $this->current_page + floor($this->mid_range/2);

        if($this->start_range <= 0)
        {
            $this->end_range += abs($this->start_range)+1;
            $this->start_range = 1;
        }
        if($this->end_range > $this->num_pages)
        {
            $this->start_range -= $this->end_range-$this->num_pages;
            $this->end_range = $this->num_pages;
        }
        $this->range = range($this->start_range,$this->end_range);

        for($i=1;$i<=$this->num_pages;$i++)
        {
            if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
            // loop through all pages. if first, last, or in range, display
            if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
            {
                $this->return .= ($i == $this->current_page And $_GET['page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
            }
            if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
        }
        $this->return .= (($this->current_page < $this->num_pages And $this->items_total >= 10) And ($_GET['page'] != 'All') And $this->current_page > 0) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$next_page&ipp=$this->items_per_page$this->querystring\">Next &raquo;</a>\n":"<span class=\"inactive\" href=\"#\">&raquo; Next</span>\n";
        $this->return .= ($_GET['page'] == 'All') ? "<a class=\"current\" style=\"margin-left:10px\" href=\"#\">All</a> \n":"<a class=\"paginate\" style=\"margin-left:10px\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    else
    {
        for($i=1;$i<=$this->num_pages;$i++)
        {
            $this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
        }
        $this->return .= "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    $this->low = ($this->current_page <= 0) ? 0:($this->current_page-1) * $this->items_per_page;
    if($this->current_page <= 0) $this->items_per_page = 0;
    $this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_items_per_page()
{
    $items = '';
    if(!isset($_GET[ipp])) $this->items_per_page = $this->default_ipp;
    foreach($this->ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n";
    return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n";
}
function display_jump_menu()
{
    for($i=1;$i<=$this->num_pages;$i++)
    {
        $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n";
    }
    return "<span class=\"paginate\">Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n";
}
function display_pages()
{
    return $this->return;
}
function handleHomePageSearch(buttonEle, e) {
    var criteria = document.getElementById("searchCriteria").value;
    var searchVal = document.getElementById("searchId").value;
    xmlHttpSearchct = new XMLHttpRequest();
    var cur_page = document.getElementById("current_page").innerHTML;

    var url = "fetchCity.php?&searchVal=" + searchVal + "&buttonEle=" + buttonEle + "&cur_page=" + cur_page;
    alert(url);

    xmlHttpSearchct.onreadystatechange = function () {
        if (xmlHttpSearchct.readyState == 4 && xmlHttpSearchct.status == 200) {
            document.getElementById('displayProp').innerHTML = xmlHttpSearchct.responseText;
        }
    }
    xmlHttpSearchct.open("GET", url, false);
    xmlHttpSearchct.send(null);
}
$(document).ready(function () {
    $('.paginate').live('click', function (e) {
        e.preventDefault();
        var btnPage = $(this);
        $.ajax({
            url: btnPage.attr('href'),
            success: function (resp) {
                // replace current results with new results.
                $('#project_section').html(resp);
            },
            error: function () {
                window.location.href = btnPage.attr('href');
            }
        });
    });
});