views:

8

answers:

0

Hi there, does any one know how to create a search form with custom fields in combobox ?

I have searched and tried to do this for weeks... and nothing... i have done so much thing with no results...

last code i´v done ( I am not a expert )

    ( cicle to get all the costum fields names ) 
<?php
                global $post;
                $tmp_post = $post;
                $myposts = get_posts('child_of=1');
                foreach($myposts as $post) :
                setup_postdata($post);
                ?>
     <?php  $option[] = get_post_meta($post->ID,'Concelho', true);  
                       $Concelho=array_unique($option); sort($Concelho); ?><!--Concelho-->                                                        
                                                          <!--Tipo de Imovel -->
                    <?php  $old_estado[] = get_post_meta($post->ID,'Estado', true); 
       $estado=array_unique($old_estado); sort($estado);      ?><!--Estado -->

                    <?php  $old_quartos[] = get_post_meta($post->ID,'Quartos', true); 
       $quartos=array_unique($old_quartos); sort($quartos);      ?><!--Quartos-->

                     <!--Preço minimo -->
                    <?php  $old_preco[] = get_post_meta($post->ID,'Preco', true); 
       $preco=array_unique($old_preco); sort($preco);      ?><!--Preço minimo -->

                    <!--Preço maximo -->
                    <?php  $old_referencia[] = get_post_meta($post->ID,'Referencia', true); 
        $referencia=array_unique($old_referencia);     ?><!--referencia -->


             <?php endforeach; ?>



( form ) 

<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>">
  <div>    
    <?php 
 $cbox = '<select name="Concelho" style="width:291px; height:25px; text-align:left; font-size:9pt; padding-top:3px; margin-top:10px;">';
 foreach($Concelho as $key=>$val) :
 $cbox .='<option value="'.$val.'" selected="false">'.$val.'</option>';    
 endforeach;

 $cbox .='<option value="" selected="true" >'.Seleccione." ".o." ".Concelho.'</option>'; 
 $cbox .= '</select>';
 echo $cbox;
 ?>



    <input type="submit" id="searchsubmit" value="Search" />
  </div>
</form>