View Single Post
  #1  
Old August 18th, 2014, 10:24 AM
alankarsale alankarsale is offline
 
Join Date: Jul 2014
Posts: 20
Default Search Code not working

Hello,

My search form is not working properly. It will do products but my merchants are coming up with any products. Can you help?

Code:
<?php
function dfr_get_merchants() {
    global $wpdb;
    $merchants = $wpdb->get_results("SELECT merchant, merchant_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
    $html = '<option value="">Select all Merchants</option>';
    foreach ($merchants as $k => $v) {
        if (trim($v->merchant) != "") {
            $selected = (strip_tags($_GET['merchant_id'])==$v->merchant_id) ? ' selected="selected"' : '';
            $html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';
        }
    }
    return $html;
}
?>

[search.form]
<div class="store_search_form">
  <p class="keyword">
    <label for="word">Keyword</label> [search.word]
  </p>
  <p class="merchant">
    <label for="word">Merchant</label>
    <select name="merchant_id">
      <?php echo dfr_get_merchants(); ?>
    </select>
  </p>
  <p class="category">
    <label for="category">Category</label> 
    <select name="c">
      <option value=""> Select all categories </option>
      [category.list before='' after='']
        <option value="[category.id]"><?php echo str_repeat ('-', (($depth-1)*2) ); ?> &nbsp; [category.name]</option>
        [category.repeat]
      [/category.list]
    </select>
  </p>
  <p class="price">
   <label for="price">Price</label> [search.selectprice options='any, Below $10(-5), $10 - $20, $20 - $30, $30 - $40, more than 40 (40+)']
  </p>
  <p class="button">[search.submit title='Find it!']</p>
</div>
[/search.form]