hybmg57 Posted July 2, 2010 Share Posted July 2, 2010 Hi, I have a search form that I built and I'm currently having difficulty sorting search results. I have set up a form with get method for displaying results and another form in a search results page with post method for sorting. I can do sorting on the first page but when I click on next page, it does not display second page... I kinda have an idea of how I might be able to solve this issue but I can't seem to find a comprehensive solution... Please have a look at my search form at below link... Please help me, this is urgent. Thank you very much! http://test1.favstay.com/Search Form.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JR Molina</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="index,follow" /> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> <link charset="utf-8" type="text/css" rel="stylesheet" media="all" href="results.css" /> <?php if (is_numeric($_GET['pg'])) { $pgnum = ((int) $_GET['pg']); } else { $pgnum = 0; $errorMessage = "Invalid value for page number"; } $startnum = 1; $nextpg = ($pgnum + 1); $prevpg = ($pgnum-1); if ($pgnum >= 0) { $offset = ($pgnum * 20); } else { $offset = 0; } $limit = 20; ?> <?php $Property_Type=$_GET['property_type']; $City=$_GET['city']; $Beds=$_GET['beds']; $Baths=$_GET['baths']; $Lowest_Price=$_GET['lowest_price']; $Highest_Price=$_GET['highest_price']; $MLS=$_GET['mls_number']; $AddressA=$_GET['address']; $Zip_codeA=$_GET['zip_code']; $SubdivisionA=$_GET['subdivision']; $GarageA=$_GET['garage']; $StoriesA=$_GET['stories']; $FireplacesA=$_GET['fireplaces']; $Yard_sizeA=$_GET['yard_size']; $CitiesA=$_GET['cities']; $AreasA=$_GET['areas']; $CountiesA=$_GET['counties']; $School_districtA=$_GET['school_district']; $School_elementaryA=$_GET['school_type[elementary]']; $School_middleA=$_GET['school_type[middle]']; $School_highA=$_GET['school_type[high]']; $School_nameA=$_GET['school_name']; $Guest_quartersA=$_GET['property[guest-quarters]']; $High_riseA=$_GET['property[high-rise-condominium]']; $Loft_A=$_GET['property[loft]']; $BalconyA=$_GET['property[balcony]']; $LibraryA=$_GET['property[library-or-study]']; $MediaA=$_GET['property[media-room]']; $Gated_communityA=$_GET['location[gated-community]']; $Golf_course_communityA=$_GET['location[golf-course-community]']; $Golf_course_lotA=$_GET['location[golf-course-lot]']; $Lake_front_lotA=$_GET['location[lake-front-lot]']; $Lake_viewA=$_GET['location[lake-view]']; $Handicap_amenitiesA=$_GET['location[handicap-ammenities]']; $Zero_lot_lineA=$_GET['location[zero-lot-line]']; $Horses_allowedA=$_GET['location[horses-allowed]']; $Fence_woodA=$_GET['fence[wood]']; $Fence_ironA=$_GET['fence[iron]']; $Fence_brickA=$_GET['fence[brick]']; $Fence_rockA=$_GET['fence[rock]']; $Fence_automatic_gateA=$_GET['fence[automatic-gate]']; $Fence_noneA=$_GET['fence[none]']; $Special_requirementsA=$_GET['special_requirements']; $Properties_with_photosA=$_GET['properties_with[photos]']; $Single_detachedA=$_GET['property_types[single-detached]']; $MultiA=$_GET['property_types[multi]']; $TownhomeA=$_GET['property_types[townhome]']; $CondoA=$_GET['property_types[condo]']; $Half_duplexA=$_GET['property_types[half-duplex]']; $LeaseA=$_GET['property_types[lease]']; $Joseph_molinaA=$_GET['only[joseph-molina-properties]']; $Open_housesA=$_GET['only[open-houses]']; include("db.php"); $rets_login_url = "http://ntreisrets.mls.ntreis.net:80/rets/login"; $rets_username = "j_Kp$06$"; $rets_password = "$33D@E862"; $rets_agent = "JKP"; require_once('phRets.php'); $rets = new phRets; $connect = $rets->Connect($rets_login_url, $rets_username, $rets_password); if (!$connect) { print_r($rets->Error()); } ?> <body id="jrmolina-listing-detail" class="our-listings our-listings-landing" text> <div id="page"> <div id="content-container"> <div id="content" class="clearfix"> <div id="container"> <form action="<?php 'Search Results.php?op=Begin+Search&pg=' . 0 . '&property_Type='.urlencode($Property_Type).'&city='.$City.'&beds='.$Beds.'&baths='.$Baths.'&lowest_price='.$Lowest_Price.'&highest_price='.$Highest_Price; ?>" method="post" id="rha-mls-our-listings-sort"> <div id="rha-mls-our-listings-sort-container"> <label for="edit-sort-by" id="for-edit-sort-by"><span>Sort By</span> <select name="sort_by" class="form-select" id="edit-sort-by" ><option value="none">Choose one</option><option value="price-high-to-low">Price Highest to Lowest</option><option value="price-low-to-high">Price Lowest to Highest</option><option value="sqft-high-to-low">Size Largest to Smallest</option><option value="sqft-low-to-high">Size Smallest to Largest</option><option value="street-name-alpha">Street Name</option><option value="listing-date-desc">Listing Date Newest to Oldest</option><option value="zip-code-numeric">Zip Code</option></select></label> <input type="submit" name="op" id="edit-submit" value="Go" class="form-submit" /> <input type="submit" name="op" id="edit-reset" value="Reset" class="form-submit" /> </div><!--/#rha-mls-our-listings-sort-container--> </form><!--/#rha-mls-our-listings-sort--> <div id="listings-container"> <div id="listings"> <?php switch($_POST['sort_by']){ case "none": $sort = "MODIFIED ASC"; break; case "price-high-to-low": $sort = "LISTPRICE DESC"; break; case "price-low-to-high": $sort = "LISTPRICE ASC"; break; } if($Highest_Price==0 || $Highest_Price=="no_limit"){ if($Highest_Price=="no_limit"){$Highest_Price="5000000";} $Any= ">="; } else { $Any= "<="; } if($City==0){ $Any_City= ">"; } else { $Any_City= "LIKE"; } if($MLS==NULL){ $Any_MLS= "IS NOT"; } else { $Any_MLS= "="; } $result = mysql_query("SELECT * FROM residential WHERE PROPSUBTYPEDISPLAY LIKE '%{$Property_Type}%' AND AREA {$Any_City} {$City} AND BEDS >={$Beds} AND BATHSTOTAL >={$Baths} AND LISTPRICE >={$Lowest_Price} AND LISTPRICE {$Any} {$Highest_Price} ORDER BY {$sort} LIMIT {$offset}, {$limit}") or die(mysql_error()); ?> <div id="rha-mls-pager-container"> <?php mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM residential WHERE PROPSUBTYPEDISPLAY LIKE '%{$Property_Type}%' AND AREA {$Any_City} {$City} AND BEDS >={$Beds} AND BATHSTOTAL >={$Baths} AND LISTPRICE >={$Lowest_Price} AND LISTPRICE {$Any} {$Highest_Price} ORDER BY {$sort} LIMIT {$offset}, {$limit}"); $total_rows = mysql_query("SELECT FOUND_ROWS()"); $total_found = mysql_fetch_array($total_rows); $pages_count= $total_found[0] / $limit; $num_pages=intval($pages_count); echo $total_found[0]." results found"; echo "<br/>"; if ($pgnum > 0) { echo("<a href='Search Results.php?op=Begin+Search&pg=" . $prevpg ."&property_Type=".urlencode($Property_Type)."&city=".$City."&beds=".$Beds."&baths=".$Baths."&lowest_price=".$Lowest_Price."&highest_price=".$_GET['highest_price']. "'><< Previous page</a> "); } if ($pgnum < $num_pages) { echo("<a href='Search Results.php?op=Begin+Search&pg=" . $nextpg . "&property_Type=".urlencode($Property_Type)."&city=".$City."&beds=".$Beds."&baths=".$Baths."&lowest_price=".$Lowest_Price."&highest_price=".$_GET['highest_price']. "'>Next page >></a> "); } echo " "; echo ($pgnum+1)." out of ".($num_pages+1)." pages"; ?> </div><!--/#rha-mls-pager-container--> <br/> <?php while ($row = mysql_fetch_array($result)){ echo "<div class=\"vcard listing\">"; echo "<div class=\"information\">"; echo "<span class=\"listprice\">\$".number_format($row['LISTPRICE'])."\n </span><br/>"; echo "<p><span>{$row['STREETNUM']},{$row['STREETNAME']} "; echo "<BR/>{$row['CITY']}</span>"; echo "{$row['STATE']}, {$row['ZIPCODE']}</p>"; echo "<p><span>Beds: {$row['BEDS']}, Baths:{$row['BATHSTOTAL']}<br/>Square Feet: ".number_format($row['SQFTTOTAL'])." </span></p>"; echo "</div>"; $photos = $rets->GetObject("Property", "Photo", "{$row['MLSNUM']}", "0", 1); foreach ($photos as $photo) { $listing = $photo['Content-ID']; $number = $photo['Object-ID']; if ($photo['Success'] == true) { echo "<img src='{$photo['Location']}\n' alt=\"\" title=\"\" class=\"listing-photo photo\" width=\"146\" height=\"107\" />"; echo "<a href=\"PropDetails.php?pg=" . $pgnum ."&property_Type=".$Property_Type."&city=".$City."&beds=".$Beds."&baths=".$Baths."&lowest_price=".$Lowest_Price."&highest_price=".$Highest_Price."&MLS=".$row['MLSNUM'].$mainp."#{$photo['Location']}"."\" class=\"button url\">See Property Details</a>"; } else { echo "<img src='images/no-image.png' alt=\"\" title=\"\" class=\"listing-photo photo\" width=\"146\" height=\"107\" />"; echo "<a href=\"PropDetails.php?MLS={$row['MLSNUM']}\" class=\"button url\">See Property Details</a>"; } } echo "</div>"; } ?> </div> </div> </div> </div> </div> </div> </body> </head> </html> Link to comment https://forums.phpfreaks.com/topic/206579-search-form-sorting-challenge-urgent/ Share on other sites More sharing options...
fenway Posted July 6, 2010 Share Posted July 6, 2010 Don't post your scripts unless you're asked to -- and you never will be. "Not displaying a page" is php, not mysql. Link to comment https://forums.phpfreaks.com/topic/206579-search-form-sorting-challenge-urgent/#findComment-1081859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.