Populating search form from database

By andybarn - April 9, 2013

Hi 

I am using the Basic Realty plugin

On the search.php file that comes with package, the search form pulldowns are hard coded with the select options.

I want to pull these in dynamically from the cmsAdmin property_type field

For example, the property_type pulldown is as follows

<td>
<select name="property_type">
<option value="">&lt;select&gt;</option>
<option value="">Any</option>
<option>Home</option>
<option>Condo</option>
<option>Townhouse</option>
<option>Apartment</option>
<option>Mobile Home</option>
<option>Lot</option>
<option>Acreage</option>
<option>Duplex</option>
<option>Triplex</option>
<option>Farm or Ranch</option>
<option>Other</option>
</select>
</td>

Please could you provide an example of the code required to populate the property_type pulldown dynamically from the database. Please use the standard form as an example so I can see how this works and then will be able to apply the code to the other pulldowns.

Thanks for your help.

Kind Regards

Andy

By andybarn - April 10, 2013

Hi Greg

Great that did the trick - thanks very much - works just how I want it!!

Just to point out for anyone else though,  you missed the opening  "<?php" from the start of your code - should read

<?php $options = getListOptions('listings', 'property_type'); ?>

Thanks again - great support and product

Andy