Results 1 to 10 of 15

Thread: Need help creating two column search

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2003
    Location
    Colorado
    Posts
    32

    Default Need help creating two column search

    I am trying to figure out how to display search drop down boxes in a two column format. I have been using OR for years and haven't had a need before now to display search in two columns.

    I have tried placing the below code in tables within listingsearch.php but just get an error as the page doesn't show. Does anyone know how to do this? I would appreciate any help. I am still using 1.15 because I have created and/or used so many mods that I can't replace with the newer OR version.

    As shown in listingsearch.php
    // Display The Agent Search
    //searchbox_agentdropdown();
    searchbox_pulldown ("Age Range:","age");
    searchbox_pulldown ("Gender:","type");
    searchbox_pulldown ("Breed:","breed");
    searchbox_pulldown ("Bred","bred");
    searchbox_pulldown ("Sire","sire");
    searchbox_pulldown ("Dam","dam");
    searchbox_pulldown ("Registration Status:","reg_status");
    searchbox_pulldown ("Uses:","uses");
    searchbox_pulldown ("Discipline:","discipline");
    searchbox_pulldown ("Temperment","temperment");

    Thanks,
    Elkman

  2. #2
    Join Date
    Feb 2003
    Location
    Omaha
    Age
    41
    Posts
    73

    Post Re: Need help creating two column search

    I highly suggest creating a custom static search page to do this. It will take you a few extra minutes to set it up but will save you time in the long run because you won't have to edit the listing search and form editor functions.

    It's actually really easy once you get the hang of it.

    1) Inside your administration panel add the fields you wish to use into the Listing Template Editor. Be sure to make the fields searchable.

    1) Open your listingsearch.php page - Example: http://www.rentomaha.com/listingsearch.php

    2) View the page source and copy the search form. Copy all of your code from <form> to </form>.

    3) Create a new search page, name it whatever you want. Example: search.php

    Since the listingsearch.php form isn't formatted here's a clean search form template for you to use.

    Code:
    <form name="listingsearch" method="get" action="listing_browse.php">
    <input type="hidden" name="type[]" value="Any Agent">
    <table cellspacing="7" width="90%" align="center">
    	<tr>
    		<td><b>Area: </b></td>
    		<td align="left"><select name="Area[]">
    		<option></option>
    		<option>Downtown</option>
    		<option>Midtown</option>
    		</select> </td>
    	</tr>
    	<tr>
    		<td><b>Bedrooms: </b></td>
    		<td align="left"><select name="beds[]">
    		<option></option>
    		<option>Studio</option>
    		<option>1 Bed</option>
    		<option>2 Bed</option>
    		</select></td>
    	</tr>
    	<tr>
    		<td><b>Bathrooms: </b></td>
    		<td align="left"><select name="baths[]">
    		<option></option>
    		<option>1 Bath</option>
    		<option>2 Bath</option>
    		</select></td>
    	</tr>
    	<tr>
    		<td><b>Garage Available: </b></td>
    		<td align="left"><select name="garage_size[]">
    		<option></option>
    		<option>Yes</option>
    		<option>No</option>
    		</select></td>
    	</tr>
    	<tr>
    		<td align="center"><b>Home Features</b></td>
    		<td align="center"><b>Community Features</b></td>
    	</tr>
    	<tr>
    		<td align="center"><select multiple size="6" name="home_features[]">
    		<option>Feature 1</option>
    		<option>Feature 2</option>
    		</select></td>
    		<td align="center">
    		<select multiple size="6" name="community_features[]">
    		<option>Feature 1</option>
    		<option>Feature 2</option>
    		</select></td>
    	</tr>
    	<tr>
    		<td align="middle" colspan="2">
    		<input type="checkbox" value="yes" name="imagesOnly"> <b>Show only listings 
    		with images</b> </td>
    	</tr>
    	<tr>
    		<td align="middle" colspan="2"><input type="submit" value="Search Now!"><form>
    		</form>
    		</td>
    	</tr>
    </table>
    4) Now look at your listingsearch.php source code and identify your search field names. Just copy the form field names and properties into the new page template I provided above. Make sure the name fields and types match.

    Note 1 - If you are saving the page into a new directory instead of your document root make sure to change the form action to the correct location of your listingsearch.php page.

    Note 2 - Notice in my example I have used a hidden input (<input type="hidden" name="type[]" value="Any Agent">). This is because I want the form to search all of the listings on the site. If you plan on providing listing searches by agent you will need to remove this field.

    5) Save your new search page, upload it to your server, and call it from your browser. Example - http://www.rentomaha.com/search.php?type=apartments.

    Note - on your search page remeber to include your config, hearder, and footer.

    Example of the completed page: search.php

    Code:
    <?php
    	include("include/common.php");
    	include("$config[template_path]/user_top.html");
    	echo "
    	<form name="listingsearch" method="get" action="listing_browse.php">
    	<input type="hidden" name="type[]" value="Any Agent">
    	<table cellspacing="7" width="90%" align="center">
    		<tr>
    			<td><b>Area: </b></td>
    			<td align="left"><select name="Area[]">
    			<option></option>
    			<option>Downtown</option>
    			<option>Midtown</option>
    			</select> </td>
    		</tr>
    		<tr>
    			<td><b>Bedrooms: </b></td>
    			<td align="left"><select name="beds[]">
    			<option></option>
    			<option>Studio</option>
    			<option>1 Bed</option>
    			<option>2 Bed</option>
    			</select></td>
    		</tr>
    		<tr>
    			<td><b>Bathrooms: </b></td>
    			<td align="left"><select name="baths[]">
    			<option></option>
    			<option>1 Bath</option>
    			<option>2 Bath</option>
    			</select></td>
    		</tr>
    		<tr>
    			<td><b>Garage Available: </b></td>
    			<td align="left"><select name="garage_size[]">
    			<option></option>
    			<option>Yes</option>
    			<option>No</option>
    			</select></td>
    		</tr>
    		<tr>
    			<td align="center"><b>Home Features</b></td>
    			<td align="center"><b>Community Features</b></td>
    		</tr>
    		<tr>
    			<td align="center"><select multiple size="6" name="home_features[]">
    			<option>Feature 1</option>
    			<option>Feature 2</option>
    			</select></td>
    			<td align="center">
    			<select multiple size="6" name="community_features[]">
    			<option>Feature 1</option>
    			<option>Feature 2</option>
    			</select></td>
    		</tr>
    		<tr>
    			<td align="middle" colspan="2">
    			<input type="checkbox" value="yes" name="imagesOnly"> <b>Show only listings 
    			with images</b> </td>
    		</tr>
    		<tr>
    			<td align="middle" colspan="2"><input type="submit" value="Search Now!"><form>
    			</form>
    			</td>
    		</tr>
    	</table>	
    	";
    	include("$config[template_path]/user_bottom.html");
    ?>
    I suggest saving the search form into an HTML file (search.html) and calling it into your search.php page. It makes editing the form much easier if you use an HTML editor such as FrontPage or Dreamweaver.

    Example:

    Code:
    <?php
    	include("include/common.php");
    	include("$config[template_path]/user_top.html");
    	include("search.html");
    	include("$config[template_path]/user_bottom.html");
    ?>
    Here's an example of our custom listing search: http://www.rentomaha.com/search.php

    I hope that helps!
    Best,
    Brad
    WWoBn Communications Group

  3. #3
    Join Date
    Nov 2004
    Location
    Sanlucar de Barrameda, Spain.
    Age
    50
    Posts
    484

    Default Re: Need help creating two column search

    You need this:
    PHP Code:
         <?php
    // get the db object in scope
    global $conn?>
    <?php searchbox_pulldown 
    (Type"type")?>
    <?php searchbox_pulldown 
    (Town"town")?>
    <?php searchbox_pulldown 
    (Located"location")?>
    Ian

  4. #4
    Join Date
    Oct 2003
    Location
    Colorado
    Posts
    32

    Default Re: Need help creating two column search

    Thanks Ian for your help.

    I created the page but wasn't sure where to place the db call. As a result the page is blank. Below is a copy of the created search.php file. Perhaps you can figure out what I need to change. I'm building this for a local horse rescue and you can see some of the listing names below.

    ///////////////////////////////////////////////////////////////////
    <?php
    include("include/common.php");
    include("$config[template_path]/user_top.html");
    ?>
    <?php
    // get the db object in scope
    global $conn; ?>
    <?php searchbox_pulldown ("Age Range:","age");
    <?php searchbox_pulldown ("Gender:","type");
    <?php searchbox_pulldown ("Breed:","breed");
    <?php searchbox_pulldown ("Bred","bred");
    <?php searchbox_pulldown ("Sire","sire");
    <?php searchbox_pulldown ("Dam","dam");
    <?php searchbox_pulldown ("Registration Status:","reg_status");
    <?php searchbox_pulldown ("Uses:","uses");
    <?php searchbox_pulldown ("Discipline:","discipline");
    <?php searchbox_pulldown ("Temperment","temperment");
    ?>

    <form name="listingsearch" method="get" action="listing_browse.php">
    <input type="hidden" name="type[]" value="Any Agent">
    <table cellspacing="7" width="90%" align="center">
    <tr>
    <td><b>Gender: </b></td>
    <td align="left"><select name="Gender[]">
    <option></option>
    <option>Mare</option>
    <option>Gelding</option>
    <option>Colt</option>
    <option>Filly</option>
    </select> </td>
    <td><b>Breed: </b></td>
    <td align="left"><select name="breed[]">
    <option></option>
    <option>Paint</option>
    <option>Quarter</option>
    <option>Arabian</option>
    <option>Mini</option>
    <option>Standard Bred</option>
    <option>Jockey Club</option>
    <option>Ranch</option>
    <option>Grade</option>
    <option>Other</option>
    </select></td>

    </tr>
    <tr>
    <td><b>Breed: </b></td>
    <td align="left"><select name="breed[]">
    <option></option>
    <option>Paint</option>
    <option>Quarter</option>
    <option>Arabian</option>
    <option>Mini</option>
    <option>Standard Bred</option>
    <option>Jockey Club</option>
    <option>Ranch</option>
    <option>Grade</option>
    <option>Other</option>
    </select></td>
    </tr>
    <tr>
    <td><b>Bred: </b></td>
    <td align="left"><select name="bred[]">
    <option></option>
    <option>No</option>
    <option>Yes</option>
    </select></td>
    </tr>
    <tr>
    <td><b>Sire: </b></td>
    <td align="left"><select name="garage_size[]">
    <option></option>
    <option>Yes</option>
    <option>No</option>
    </select></td>
    </tr>
    <tr>
    <td align="center"><b>Disciplines</b></td>
    <td align="center"><b>Uses</b></td>
    </tr>
    <tr>
    <td align="center"><select multiple size="6" name="discipline[]">
    <option>Ranch</option>
    <option>Work</option>
    <option>Heading</option>
    <option>Heeling</option>
    <option>Calf</option>
    <option>Steer</option>
    <option>Stopping</option>
    <option>Reining</option>
    <option>Cowhorse</option>
    <option>Trails</option>
    </select></td>
    <td align="center">
    <select multiple size="6" name="uses[]">
    <option>Ranch</option>
    <option>Family</option>
    <option>Kids</option>
    <option>Lessons</option>
    <option>Fun</option>
    <option>Pet</option>
    <option>Trail</option>
    <option>Packing</option>
    <option>Am Show</option>
    <option>Open Show</option>
    <option>Training</option>
    <option>Gymkana</option>
    </select></td>
    </tr>
    <tr>
    <td align="middle" colspan="2">
    <input type="checkbox" value="yes" name="imagesOnly"> <b>Show only listings
    with images</b> </td>
    </tr>
    <tr>
    <td align="middle" colspan="2"><input type="submit" value="Search Now!"><form>
    </form>
    </td>
    </tr>
    </table>

    ?>
    <?php
    include("$config[template_path]/user_bottom.html");
    ?>

    /////////////////////////////////////////////////////////////////////////

    Doing this I realize I have another question. I would like to allow people to also search by age ranges and price ranges. Can this still be done using this format? The horses range from 1 to 35 years old and may people would rather use a range in selecting horses to look at. My wife is a vetinary tech and it seems we're always helping to save one animal or another. :-)

    Thank again for you help. It really is appreciated!

    Bill

  5. #5
    Join Date
    Oct 2003
    Location
    Colorado
    Posts
    32

    Default Re: Need help creating two column search

    Hey Ian,

    I realized as soon as I posted the above code that the code was wrong. Should be like this: <?php searchbox_pulldown ("Age Range:","age")?>

    The problem I have is that I can now control the layout thanks to you. However, even though the correct codes are in place the information isn't being pulled from the database. What am I doing wrong? I really appreciate your help on this.

    This code works:

    <?php
    // get the db object in scope
    global $conn; ?>
    <?php searchbox_pulldown ("Temperment","temperment") ?>
    <?php searchbox_pulldown ("Sire","sire") ?>
    <?php searchbox_pulldown ("Dam","dam") ?>
    <?php searchbox_pulldown ("Registration Status:","reg_status") ?>
    <?php searchbox_pulldown ("Uses:","uses") ?>
    <?php searchbox_pulldown ("Discipline:","discipline") ?>
    <?php searchbox_pulldown ("Age Range:","age")?>
    <?php searchbox_pulldown ("Gender:","type") ?>
    <?php searchbox_pulldown ("Breed:","breed") ?>
    <?php searchbox_pulldown ("Bred","bred") ?>

    However, I still can't seem to separate the results into two side by side columns.

    Any ideas? Thanks,

    Bill

  6. #6
    Join Date
    Nov 2004
    Location
    Sanlucar de Barrameda, Spain.
    Age
    50
    Posts
    484

    Default Re: Need help creating two column search

    The code needs to be within the <form></form> for it to be processed on the next page.

    Might also be missing the micro time code , on my home page I don't need this but on my advanced search page I do...!
    PHP Code:
    //for header
    function getmicrotime(){
    list(
    $usec$sec) = explode(" ",microtime());
    return ((float)
    $usec + (float)$sec);
    }
    $start_time getmicrotime()
    ?> 
    Send us the html file to the email address I've pm'ed to you and I'll take a look if the above doesn't work.

    Ian

    Ian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •