Search Problem

5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 25, 2009   (RSS)

By blind2uriz - February 23, 2009

Here's the first problem. I made a search form and started to test it out. Almost everything worked fine. The problem I was running into was, if I searched "Single Family", every "single family" came up, but if I searched "Single Family" with say "2" bedrooms, all "Single Family" would come up w/ different bedrooms. I was having trouble syncing them up. Any thoughts on how to fix that? Do I need to put values in every label?

The second problem is, the biggest issue now, now every time I search it tells me that there are no records found. No matter what I search. I can just put "Single Family" and nothing shows up. Very strange. Here is my form. Any thoughts?

<form id="form1" name="form1" method="post" action="http://www.idsitepreview.com/listingList.php">
<table width="746" height="60" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#084d09">
<td width="124" height="38" valign="bottom"><div align="center" class="style2">Property Type:</div></td>
<td width="78" valign="bottom"><div align="center" class="style2">Bedrooms:</div></td>
<td width="205" valign="bottom"><div align="center" class="style2">Price: </div></td>
<td width="79" valign="bottom"><div align="center" class="style2">Bathrooms:</div></td>
<td valign="bottom"><div align="center" class="style2">Sort Order:</div></td>
<td valign="bottom">&nbsp;</td>
</tr>
<tr>
<td align="center"><select name="property_type" id="property_type">
<option value="" selected="selected">Any</option>
<option value="Commecial">Commercial</option>
<option value="Farm">Farm</option>
<option value="Land">Land</option>
<option value="Lot">Lot</option>
<option value="Mfd/Mobile">MFD/Mobile</option>
<option value="Single Family">Single Family</option>
<option value="Multi-Family">Multi-Family</option>
</select></td>
<td align="center"><select name="bedrooms" id="bedrooms">
<option value="">Any</option>
<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></td>
<td align="center"><select name="price">
<option value="" selected="selected">Minimum </option>
<option value="">Any</option>
<option>$0</option>
<option>$50,000</option>
<option>$75,000</option>
<option>$100,000</option>
<option>$125,000</option>
<option>$150,000</option>
<option>$175,000</option>
<option>$200,000</option>
<option>$250,000</option>
<option>$500,000</option>
</select>
<select name="price">
<option value="" selected="selected">Maximum </option>
<option value="">Unlimited </option>
<option>$50,000</option>
<option>$75,000</option>
<option>$100,000</option>
<option>$125,000</option>
<option>$150,000</option>
<option>$175,000</option>
<option>$200,000</option>
<option>$250,000</option>
<option>$500,000</option>
<option>$1,000,000</option>
<option>$2,000,000</option>
</select></td>
<td align="center"><label>
<select name="bathrooms" id="bathrooms">
<option>Any</option>
<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>
<option value="6">6</option>
</select>
</label></td>
<td width="180"><label>
<select name="sort" id="sort">
<option>Any</option>
<option value="price DESC">By Price (High to Low)</option>
<option value="price ASC">By Price (Low to High)</option>
<option value="bedrooms ASC">Beds (High to Low)</option>
<option value="bedrooms DESC">Beds (Low to High)</option>
<option value="bathrooms ASC">Bathrooms (High to Low)</option>
<option value="bathrooms DESC">Bathrooms (Low to High)</option>
</select>
</label></td>
<td width="80" align="center"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
</form>

Also, does that look like what I want to be putting for sort order? Any help is greatly appreciated before I pull my hair out.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Search Problem

By Dave - February 24, 2009

Hi John,

A couple more tips to help debug this.

Change your form from POST to GET: <form id="form1" name="form1" method="GET" action="http://www.idsitepreview.com/listingList.php">

This will make all the search criteria show up in the url where you can more easily see (and modify or test) what is being submitted. You can change it back later when it's working if you like.

Enter numeric searches as whole numbers without extra characters. For example, change this: <option>$100,000</option> to this: <option value="100000">$100,000</option> otherwise the numeric searches won't work properly.

Next, if you're passing sort order directly to mysql make sure you're escaping it or it could make the page insecure.

Try those changes and if you're still having troubles attach your viewer file and we can take a look.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Search Problem

By blind2uriz - February 24, 2009

Thanks for the form example sagentic, it works great!

Thanks for the reply Dave and your information as well, but I'm confused on what you mean about sorting. How do I escape it? I've never tried to sort anything, so I went to sorting in CMSBuilder and put in my field names and added DESC to each, then just typed the corresponding name in the sort order field in the form. Do I need to do anything extra in on either side? Thanks for all your help.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Search Problem

By Dave - February 25, 2009

Hi John,

The viewers don't support specifying sort order through a form yet. Only hard coding it in the admin program or source of the viewer page. The only way to do it currently is with a little bit of custom code.

Once you have everything else working start a new thread about that and attach your viewer file if you can and I'll help you out with it.
Dave Edis - Senior Developer
interactivetools.com