1
我們在我們網站的主頁上設置了一個搜索表單,以在不同的頁面上顯示房產結果。網站訪問者可以在首頁上選擇價格,城市等,然後重定向到不同頁面上查看結果。當他們在結果頁面上選擇一個屬性時,可以選擇返回搜索結果。搜索表單重定向到結果頁面
當網站訪問者從主頁搜索,查看其中一個結果,然後返回搜索結果時,它會顯示數據庫中的所有列表而不是搜索結果。
我們在結果頁上也有搜索表單。當訪問者從該頁面上的搜索表單中進行搜索時,查看列表,點擊返回到搜索結果,它會顯示正確的搜索結果。
這是我們正在使用的代碼:
搜索表單主頁:結果頁面上
<form class="form-horizontal" method="post" action="/wp/residential-listings/">
<fieldset>
<!-- Form Name -->
<h1 style="color:#ffffff; text-align:center;">FIND YOUR NEW HOME</h1>
<div class="row">
<div class="form-group">
<!-- Select Basic -->
<div class="col-sm-4" style="text-align:center;"><label for="city">City:</label>
<select id="city" name="city" class="form-control">
<option value="all-cities" disabled">Select:</option>
<option value="all-cities" disabled>DeKalb County</option>
<option value="COLLINSVILLE"> Collinsville</option>
<option value="CROSSVILLE"> Crossville</option>
<option value="DAWSON"> Dawson</option>
<option value="FLAT ROCK"> Flat Rock</option>
<option value="FORT PAYNE"> Fort Payne</option>
<option value="FYFFE"> Fyffe</option>
<option value="GERALDINE"> Geraldine</option>
<option value="HAMMONDVILLE"> Hammondville</option>
<option value="HENAGAR"> Henagar</option>
<option value="IDER"> Ider</option>
<option value="MENTONE"> Mentone</option>
<option value="PISGAH"> Pisgah</option>
<option value="POWELL"> Powell</option>
<option value="RAINSVILLE"> Rainsville</option>
<option value="SECTION"> Section</option>
<option value="VALLEY HEAD"> Valley Head</option>
<option value="all-cities" disabled>Cherokee County</option>
<option value="CEDAR BLUFF"> Cedar Bluff</option>
<option value="CEDARTOWN"> Cedartown</option>
<option value="CENTRE"> Centre</option>
<option value="CHEROKEE"> Cherokee</option>
<option value="LEESBURG"> Leesburg</option>
<option value="PAINT ROCK"> Paint Rock</option>
<option value="SAND ROCK"> Sand Rock</option>
<option value="SECTION"> Section</option>
<option value="all-cities" disabled>Jackson County</option>
<option value="BRIDGEPORT"> Bridgeport</option>
<option value="DUTTON"> Dutton</option>
<option value="GURLEY"> Gurley</option>
<option value="HOKES BLUFF"> Hokes Bluff</option>
<option value="HOLLYWOOD"> Hollywood</option>
<option value="HYTOP"> Hytop</option>
<option value="SCOTTSBORO"> Scottsboro</option>
<option value="STEVENSON"> Stevenson</option>
</select></div>
<!-- Select Basic -->
<div class="col-sm-4" style="text-align:center;"><label for="price-min">Min. Price:</label>
<select id="price-min" name="price-min" class="form-control">
<option value="0">No Minimum</option>
<option value="50000">50,000</option>
<option value="100000">100,000</option>
<option value="150000">150,000</option>
<option value="200000">200,000</option>
<option value="250000">250,000</option>
<option value="300000">300,000</option>
<option value="350000">350,000</option>
<option value="400000">400,000</option>
<option value="450000">450,000</option>
<option value="500000">500,000</option>
</select></div>
<!-- Select Basic -->
<div class="col-sm-4" style="text-align:center;"><label for="price-max">Max. Price:</label>
<select id="price-max" name="price-max" class="form-control">
<option value="999999999">No Maximum</option>
<option value="100000">100,000</option>
<option value="150000">150,000</option>
<option value="200000">200,000</option>
<option value="250000">250,000</option>
<option value="300000">300,000</option>
<option value="350000">350,000</option>
<option value="400000">400,000</option>
<option value="450000">450,000</option>
<option value="500000">500,000</option>
<option value="999999999">No Maximum</option>
</select></div>
<!-- Select Basic -->
<div class="col-sm-6" style="text-align:center;"><label for="beds">Min. Beds:</label>
<select id="beds" name="beds" class="form-control">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div>
<!-- Select Basic -->
<div class="col-sm-6" style="text-align:center;"><label for="baths">Min. Baths:</label>
<select id="baths" name="baths" class="form-control">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div>
</div>
</div>
<div class="form-group">
<div class="col-md-12" style="text-align:center;">
<button class="fusion-button button-flat button-round button-large button-default button-1" type="submit" value="SEARCH" style="text-align:center;">SEARCH</button>
</div>
</div>
</fieldset>
</form>
搜索表單:
<form method="post" action="/wp/residential-listings/">
<div class="fusion-fullwidth fullwidth-box nonhundred-percent-fullwidth fusion-equal-height-columns fusion-no-small-visibility fusion-no-medium-visibility" style='background-color: #6a1d1e;background-position: center center;background-repeat: no-repeat;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;margin-bottom: 5px;'><div class="fusion-builder-row fusion-row" style="margin-left:50px;margin-top:10px;"><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth fusion-column-first 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));margin-right: 4%;'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<h2 style="color: #ffffff; text-align: center;">City:</h2>
<p style="text-align: center;"><select id="city" class="form-control" name="city"><option value="all-cities" <?php if($qs_city=="all-cities"){echo "selected";}?>>Select:</option><option value="all-cities" disabled>DeKalb County</option><option value="COLLINSVILLE" <?php if($qs_city=="COLLINSVILLE"){echo "selected";}?>> Collinsville</option><option value="CROSSVILLE" <?php if($qs_city=="CROSSVILLE"){echo "selected";}?>> Crossville</option><option value="DAWSON" <?php if($qs_city=="DAWSON"){echo "selected";}?>> Dawson</option><option value="FLAT ROCK" <?php if($qs_city=="FLAT ROCK"){echo "selected";}?>> Flat Rock</option><option value="FORT PAYNE" <?php if($qs_city=="FORT PAYNE"){echo "selected";}?>> Fort Payne</option><option value="FYFFE" <?php if($qs_city=="FYFFE"){echo "selected";}?>> Fyffe</option><option value="GERALDINE" <?php if($qs_city=="GERALDINE"){echo "selected";}?>> Geraldine</option><option value="HAMMONDVILLE" <?php if($qs_city=="HAMMONDVILLE"){echo "selected";}?>> Hammondville</option><option value="HENAGAR" <?php if($qs_city=="HENAGAR"){echo "selected";}?>> Henagar</option><option value="IDER" <?php if($qs_city=="IDER"){echo "selected";}?>> Ider</option><option value="MENTONE" <?php if($qs_city=="MENTONE"){echo "selected";}?>> Mentone</option><option value="PISGAH" <?php if($qs_city=="PISGAH"){echo "selected";}?>> Pisgah</option><option value="POWELL" <?php if($qs_city=="POWELL"){echo "selected";}?>> Powell</option><option value="RAINSVILLE" <?php if($qs_city=="RAINSVILLE"){echo "selected";}?>> Rainsville</option><option value="SECTION" <?php if($qs_city=="SECTION"){echo "selected";}?>> Section</option><option value="VALLEY HEAD" <?php if($qs_city=="VALLEY HEAD"){echo "selected";}?>> Valley Head</option><option value="all-cities" disabled>Cherokee County</option><option value="CEDAR BLUFF" <?php if($qs_city=="CEDAR BLUFF"){echo "selected";}?>> Cedar Bluff</option><option value="CEDARTOWN" <?php if($qs_city=="CEDARTOWN"){echo "selected";}?>> Cedartown</option><option value="CENTRE" <?php if($qs_city=="CENTRE"){echo "selected";}?>> Centre</option><option value="CHEROKEE" <?php if($qs_city=="CHEROKEE"){echo "selected";}?>> Cherokee</option><option value="LEESBURG" <?php if($qs_city=="LEESBURG"){echo "selected";}?>> Leesburg</option><option value="PAINT ROCK" <?php if($qs_city=="PAINT ROCK"){echo "selected";}?>> Paint Rock</option><option value="SAND ROCK" <?php if($qs_city=="SAND ROCK"){echo "selected";}?>> Sand Rock</option><option value="all-cities" disabled>Jackson County</option><option value="BRIDGEPORT" <?php if($qs_city=="BRIDGEPORT"){echo "selected";}?>> Bridgeport</option><option value="DUTTON" <?php if($qs_city=="DUTTON"){echo "selected";}?>> Dutton</option><option value="GURLEY" <?php if($qs_city=="GURLEY"){echo "selected";}?>> Gurley</option><option value="HOKES BLUFF" <?php if($qs_city=="HOKES BLUFF"){echo "selected";}?>> Hokes Bluff</option><option value="HOLLYWOOD" <?php if($qs_city=="HOLLYWOOD"){echo "selected";}?>> Hollywood</option><option value="HYTOP" <?php if($qs_city=="HYTOP"){echo "selected";}?>> Hytop</option><option value="SCOTTSBORO" <?php if($qs_city=="SCOTTSBORO"){echo "selected";}?>> Scottsboro</option><option value="STEVENSON" <?php if($qs_city=="STEVENSON"){echo "selected";}?>> Stevenson</option></select></p><div class="fusion-clearfix"></div>
</div>
</div><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));margin-right: 4%;'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<h2 style="text-align: center;"><span style="color: #ffffff;">Min. Price: </span></h2>
<p style="text-align: center;"><select id="price-min" class="form-control" name="price-min"><option value="0" <?php if($qs_price_min=="0"){echo "selected";}?>>No Minimum</option><option value="50000" <?php if($qs_price_min=="50000"){echo "selected";}?>>50,000</option><option value="100000" <?php if($qs_price_min=="100000"){echo "selected";}?>>100,000</option><option value="150000" <?php if($qs_price_min=="150000"){echo "selected";}?>>150,000</option><option value="200000" <?php if($qs_price_min=="200000"){echo "selected";}?>>200,000</option><option value="250000" <?php if($qs_price_min=="250000"){echo "selected";}?>>250,000</option><option value="300000" <?php if($qs_price_min=="300000"){echo "selected";}?>>300,000</option><option value="350000" <?php if($qs_price_min=="350000"){echo "selected";}?>>350,000</option><option value="400000" <?php if($qs_price_min=="400000"){echo "selected";}?>>400,000</option><option value="450000" <?php if($qs_price_min=="450000"){echo "selected";}?>>450,000</option><option value="500000" <?php if($qs_price_min=="500000"){echo "selected";}?>>500,000</option></select></p><div class="fusion-clearfix"></div>
</div>
</div><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));margin-right: 4%;'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<h2 style="text-align: center;"><span style="color: #ffffff;">Max. Price:</span></h2>
<p style="text-align: center;"><select id="price-max" class="form-control" name="price-max"><option value="999999999" <?php if($qs_price_max=="999999999"){echo "selected";}?>>No Maximum</option><option value="100000" <?php if($qs_price_max=="100000"){echo "selected";}?>>100,000</option><option value="150000" <?php if($qs_price_max=="150000"){echo "selected";}?>>150,000</option><option value="200000" <?php if($qs_price_max=="200000"){echo "selected";}?>>200,000</option><option value="250000" <?php if($qs_price_max=="250000"){echo "selected";}?>>250,000</option><option value="300000" <?php if($qs_price_max=="300000"){echo "selected";}?>>300,000</option><option value="350000" <?php if($qs_price_max=="350000"){echo "selected";}?>>350,000</option><option value="400000" <?php if($qs_price_max=="400000"){echo "selected";}?>>400,000</option><option value="450000" <?php if($qs_price_max=="450000"){echo "selected";}?>>450,000</option><option value="500000" <?php if($qs_price_max=="500000"){echo "selected";}?>>500,000</option><option value="999999999">No Maximum</option></select></p><div class="fusion-clearfix"></div>
</div>
</div><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));margin-right: 4%;'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<h2 style="text-align: center;"><span style="color: #ffffff;">Beds:</span></h2>
<p style="text-align: center;"><select id="beds" class="form-control" name="beds"><option value="1" <?php if($qs_beds=="1"){echo "selected";}?>>1</option><option value="2" <?php if($qs_beds=="2"){echo "selected";}?>>2</option><option value="3" <?php if($qs_beds=="3"){echo "selected";}?>>3</option><option value="4" <?php if($qs_beds=="4"){echo "selected";}?>>4</option><option value="5" <?php if($qs_beds=="5"){echo "selected";}?>>5</option></select></p><div class="fusion-clearfix"></div>
</div>
</div><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));margin-right: 4%;'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<h2 style="text-align: center;"><span style="color: #ffffff;">Baths:</span></h2>
<p style="text-align: center;"><select id="baths" class="form-control" name="baths"><option value="1" <?php if($qs_baths=="1"){echo "selected";}?>>1</option><option value="2" <?php if($qs_baths=="2"){echo "selected";}?>>2</option><option value="3" <?php if($qs_baths=="3"){echo "selected";}?>>3</option><option value="4" <?php if($qs_baths=="4"){echo "selected";}?>>4</option><option value="5" <?php if($qs_baths=="5"){echo "selected";}?>>5</option></select></p><div class="fusion-clearfix"></div>
</div>
</div><div class="fusion-layout-column fusion_builder_column fusion_builder_column_1_6 fusion-one-sixth fusion-column-last 1_6" style='margin-top:0px;margin-bottom:20px;width:16.66%;width:calc(16.66% - ((4% + 4% + 4% + 4% + 4%) * 0.1666));'>
<div class="fusion-column-wrapper" style="background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;" data-bg-url="">
<p style="text-align:center;"><button class="fusion-button button-flat button-round button-large button-default button-1" type="submit" value="SEARCH">SEARCH</button></p><div class="fusion-clearfix"></div>
</div>
</div></div></div></form>
'返回搜索' 按鈕/鏈接:
<a href="javascript:history.go(-1)">Back to Search</a>
我認爲這可能是因爲主頁搜索表單不顯示在顯示結果的頁面上。任何幫助將不勝感激!如有必要,我可以提供更多信息或代碼。