Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 8, 2017

I'd appreciate some help with making this search form work
Tks, Larry

<form method="POST" action="/vendors.php">
Choose State to Search &nbsp;
<select name="state1">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
</select>
<br><br>
Choose Type of Festival:<br>
<input type=checkbox name="type_vendor" value="FandB"> Food and Beverage<br>
<input type=checkbox name="type_vendor" value="Product"> Arts, Crafts, Product<br>
<input type=checkbox name="type_vendor" value="Service"> Service Provider<br>
<input type=checkbox name="type_vendor" value="Attraction"> Attraction<br>
<br>

<input type="submit" name="submit" value="Search">
</form>

The problem seemed to be that you should not have an underscore in a field name used in the search form.

Then it worked great

Hi dlsweb, 

The underscore in the fieldname shouldn't cause a problem.  Here's a couple tips and things to look out for, though: 

For your state pulldown, you may want to provide an option to list all states: 

<select name="state1">
<option value="">&lt;any&gt;</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
</select>

And for your check boxes, each option will overwrite the previous.  If you want to show records that match ANY of the checked boxes (performs an OR search query) you need to add square brackets to tell PHP to submit the values as an array instead of overwriting each other: 

<input type=checkbox name="type_vendor[]" value="FandB"> Food and Beverage<br>
<input type=checkbox name="type_vendor[]" value="Product"> Arts, Crafts, Product<br>
<input type=checkbox name="type_vendor[]" value="Service"> Service Provider<br>
<input type=checkbox name="type_vendor[]" value="Attraction"> Attraction<br>

And for debugging you can see the actual MySQL being generated and executed by temporarily adding this option: 

    'debugSql' => true,

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com