Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3609650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:39:16+00:00 2026-05-18T21:39:16+00:00

<?php if(isset($_REQUEST[‘searchcat’])) { $search_category = $_REQUEST[‘searchcat’]; switch($search_category) { case ‘Purchase’: $city = mysql_real_escape_string($_REQUEST[‘city’]); $location

  • 0
<?php
      if(isset($_REQUEST['searchcat']))
  {
        $search_category = $_REQUEST['searchcat'];
        switch($search_category)
        {
            case 'Purchase':
                $city      = mysql_real_escape_string($_REQUEST['city']);
                $location  = mysql_real_escape_string($_REQUEST['location']);
                $bedrooms  = mysql_real_escape_string($_REQUEST['noofbedrooms']);
                $addeddate = mysql_real_escape_string($_REQUEST['addeddate']);
                $minprice  = mysql_real_escape_string($_REQUEST['pricefrom']);
                $maxprice  = mysql_real_escape_string($_REQUEST['priceto']);
                $minarea   = mysql_real_escape_string($_REQUEST['areafrom']);
                $maxarea   = mysql_real_escape_string($_REQUEST['areato']);
                $proptype   = mysql_real_escape_string($_REQUEST['proptype']);
                $addeddate = date($addeddate * 24 * 60 * 60);
                $query = 'SELECT image,propertytitle,propertypurpose,propertytype,city,id FROM properties WHERE 1 = 1 AND propertypurpose = "Purchase" ';
                $query .= strlen($city)     ? ' AND city = "'.$city.'"'         : '';
                $query .= strlen($location) ? ' AND location = "'.$location.'"' : '';
                $query .= strlen($bedrooms) ? ' AND bedrooms = "'.$bedrooms.'"' : '';
                if($addeddate!=0)
                    $query .= strlen($addeddate) ? ' AND dateadded >= "FROM_UNIXTIME('.$addeddate.')"' : '';
                $query .= strlen($minprice) ? ' AND price between "'.$minprice.'"' : '';
                $query .= strlen($maxprice) ? ' AND "'.$maxprice.'"' : '';
                $query .= strlen($minarea) ? ' AND landarea between "'.$minarea.'"' : '';
                $query .= strlen($maxarea) ? ' AND "'.$maxarea.'"' : '';
                $query .= strlen($proptype) ? ' AND propertytype = "'.$proptype.'"' : '';
                $getSearchRowsQuery = explode('properties',$query);
                $getSearchRowsQuery = 'SELECT COUNT(id) As numrows FROM properties' . $getSearchRowsQuery[1];
                break;
            case 'rentals':
                break;
            case 'agents':
                break;
            case 'developments':
                break;
            default:
        }
    }
    $classObject = new class_functions();
    $rowsPerPage = 2;
    // by default we show first page
    $pageNum = 1;
    // if $_GET['page'] defined, use it as page number
    if(isset($_GET['page']))
    {
        $pageNum = $_GET['page'];
    }
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    if(!isset($_REQUEST['searchcat']))
    {
        if(!isset($_REQUEST['page']))
        {
            $query = '';
            session_destroy($_SESSION['searchquery']);
            session_destroy($_SESSION['searchcount']);
        }
        else 
            $query = $_SESSION['searchquery'];
    }
else 
{
    session_destroy($_SESSION['searchquery']);
    session_destroy($_SESSION['searchcount']);
}
if(isset($_SESSION['searchquery']))
    $query = $_SESSION['searchquery'];
$tmpquery = $query . ' LIMIT ' . $offset . ', ' .$rowsPerPage;
echo $tmpquery;
$listings[] = $classObject->getSearchListings($tmpquery,$offset,$rowsPerPage);
for($i=0;$i<sizeof($listings[0]);$i++) {
    if($i%2==0)
        echo '<tr class="oddrow">';
    else
        echo '<tr>';
?>
    <td class="colimage">
            <?php if($listings[0][$i][0]=="") {?>
            <a href="#"><img src="images/no-image.png" alt="no image" /></a>
                            <?php } else {?>
                                <a href="#"><img src="<?php echo $listings[0][$i][0]; ?>" alt="<?php echo $featured[0][$i][1]; ?>" /></a><?php }?>
                        </td>
                        <td class="coltitle"><?php echo $listings[0][$i][1]; ?></td>
                        <td class="colpurpose"><?php echo $listings[0][$i][2]; ?></td>
                        <td class="coltype"><?php echo $listings[0][$i][3]; ?></td>
                        <td class="colcity"><?php echo $listings[0][$i][4]; ?></td>
                    </tr>

                    <?php } ?>
                 </table>
                    <?php
                        //echo $getSearchRowsQuery;
                        if(!isset($_SESSION['searchcount']))
                            $numrows = $classObject->get_search_rows($getSearchRowsQuery);
                        else 
                            $numrows = $_SESSION['searchcount'];
                        if($numrows==0)
                        {
                            echo 'No records found.';
                        }
                        else 
                        {
                            // how many pages we have when using paging?
                            $maxPage = ceil($numrows/$rowsPerPage);

                            // print the link to access each page
                            $self = $_SERVER['PHP_SELF'];
                            $nav  = '';

                            for($page = 1; $page <= $maxPage; $page++)
                            {
                               if ($page == $pageNum)
                               {
                                  $nav .= " $page "; // no need to create a link to current page
                               }
                               else
                               {
                                  $nav .= " <a href=\"$self?page=$page\">$page</a> ";
                                  $_SESSION['searchquery'] = $query;
                                  $_SESSION['searchcount'] = $numrows;
                               }
                            }
                            if ($pageNum > 1)
                            {
                               $page  = $pageNum - 1;
                               $prev  = " <a href=\"$self?page=$page\">[Prev]</a> ";

                               $first = " <a href=\"$self?page=1\">[First Page]</a> ";
                            }
                            else
                            {
                               $prev  = '&nbsp;'; // we're on page one, don't print previous link
                               $first = '&nbsp;'; // nor the first page link
                            }

                            if ($pageNum < $maxPage)
                            {
                               $page = $pageNum + 1;
                               $next = " <a href=\"$self?page=$page\">[Next]</a> ";

                               $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
                            }
                            else
                            {
                               $next = '&nbsp;'; // we're on the last page, don't print next link
                               $last = '&nbsp;'; // nor the last page link
                            }
                        }
                    ?>

My question is that how can i repeat the query on next pages using sessions. i.e i want to store the query if the pages exceeds results from 1 page. basically listing. I cant figure out the logic for storing the query and check for condition that the page is loaded first time or it is continuing search result.

sorry for improper formatting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:39:17+00:00Added an answer on May 18, 2026 at 9:39 pm

    Well, ASP defines property IsPostBack for every page which answers your question whether page has been loaded before. You can use same technique by creating custom bussiness class instance of which you store in $_SESSION[‘bl’] and check if $_SESSION[‘bl’] is null. In that class you could define properties that store your query and other desired parameters. Then you’ll have all information you need and can go from there

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this code: <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
PHP has a very nice function, isset($variableName). It checks if $variableName is already defined
<?php $var = NULL; var_dump(isset($var)); // bool(false) var_dump(isset($unset_var)); // bool(false) ?> isset($var) should return
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
I have the following pages: page1.php <?php if (isset($_GET['link'])) { session_start(); $_session['myvariable'] = 'Hello
My email code isn't working. <?php if(isset($_POST['send'])){ $to = info@erbimages.com ; // change all
I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set
PHP has a great function called htmlspecialcharacters() where you pass it a string and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.