Exemple #1
0
 function cp_show_refine_search($catid)
 {
     global $wpdb;
     $fid = '';
     // get the category ids from all the form_cats fields.
     // they are stored in a serialized array which is why
     // we are doing a separate select. If the form is not
     // active, then don't return any cats.
     $results = $wpdb->get_results("SELECT ID, form_cats FROM {$wpdb->cp_ad_forms} WHERE form_status = 'active'");
     if ($results) {
         // now loop through the recordset
         foreach ($results as $result) {
             // put the form_cats into an array
             $catarray = unserialize($result->form_cats);
             // now search the array for the $catid which was passed in via the cat drop-down
             if (in_array($catid, $catarray)) {
                 $fid = $result->ID;
             }
             // when there's a catid match, grab the form id
         }
         // now we should have the formid so show the form layout based on the category selected
         $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, m.field_search, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "AND f.field_type <> 'text area' " . "AND m.field_search = '1' " . "ORDER BY m.field_pos ASC", $fid);
         $results = $wpdb->get_results($sql);
         // echo $sql;
         //print_r($results);
         if ($results) {
             echo cp_refine_search_builder($results);
         }
         // loop through the custom form fields and display them
     }
 }
Exemple #2
0
 function cp_show_refine_search($cat_id)
 {
     global $wpdb;
     $form_id = cp_get_form_id($cat_id);
     if (!$form_id) {
         return;
     }
     // now we should have the formid so show the form layout based on the category selected
     $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, m.field_search, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m ON f.field_id = m.field_id " . "WHERE m.form_id = %s AND m.field_search = '1' " . "ORDER BY m.field_pos ASC", $form_id);
     $results = $wpdb->get_results($sql);
     if ($results) {
         echo cp_refine_search_builder($results);
         // loop through the custom form fields and display them
     }
 }