function getFilterQueryString() { $where = ""; $android = getFilterValue("android"); if (strlen($android) > 0) { $where = '`android_version`="' . mysql_real_escape_string($android) . '" '; } $brand = getFilterValue("brand"); if (strlen($brand) > 0) { if (strlen($where) > 0) { $where = $where . ' AND ' . '`phone_brand`="' . mysql_real_escape_string($brand) . '" '; } else { $where = $where . '`phone_brand`="' . mysql_real_escape_string($brand) . '" '; } } $model = getFilterValue("model"); if (strlen($model) > 0) { if (strlen($where) > 0) { $where = $where . ' AND ' . '`phone_model`="' . mysql_real_escape_string($model) . '" '; } else { $where = '`phone_model`="' . mysql_real_escape_string($model) . '" '; } } if (strlen($where) > 0) { $where = " AND " . $where; } return $where; }
function outputDefaultFilterData() { $android_list = getList("", "android_version"); $android_list = outputList($android_list); $brand_list = getList("", "phone_brand"); $brand_list = outputList($brand_list); $model_list = getList("", "phone_model"); $model_list = outputList($model_list); $android = getFilterValue("android"); $brand = getFilterValue("brand"); $model = getFilterValue("model"); $android_data = array('id' => "android", 'selected' => getSelectedIndex($android, $android_list), 'list' => $android_list); $brand_data = array('id' => "brand", 'selected' => getSelectedIndex($brand, $brand_list), 'list' => $brand_list); $model_data = array('id' => "model", 'selected' => getSelectedIndex($model, $model_list), 'list' => $model_list); $out = array($android_data, $brand_data, $model_data); echo json_encode($out); }
<?php require 'acra_filter_api.php'; if (isset($_REQUEST['data'])) { set_acra_filter(json_decode($_REQUEST['data'])); } if (isset($_REQUEST['sender'])) { $android_list = array(''); $brand_list = array(''); $model_list = array(''); $condition = ''; $android = getFilterValue("android"); $brand = getFilterValue("brand"); $model = getFilterValue("model"); switch ($_REQUEST['sender']) { case 'android': if (strlen($android) === 0) { //user select all, the filter does not change if (strlen($brand) == 0) { $android_list = getList("", "android_version"); $android_list = outputList($android_list); $brand_list = getList("", "phone_brand"); $brand_list = outputList($brand_list); $model_list = getList("", "phone_model"); $model_list = outputList($model_list); } else { $sql = "`phone_brand`='" . mysql_real_escape_string($brand) . "'"; $android_list = getList($sql, "android_version"); $android_list = outputList($android_list); $brand_list = getList("", "phone_brand"); $brand_list = outputList($brand_list);
</label> </div> <div class="categories_left_line"> <label for="special_offer"> <?php echo form_checkbox('special_offer', 'on', getFilterValue("special_offer", $active_filters), 'id="special_offer"'); ?> Promotii </label> </div> <div class="categories_left_line"> <label for="producer"> Producator <?php echo form_dropdown('producer', $producers_dropdown, getFilterValue("producer", $active_filters), 'id="producer"'); ?> </label> </div> <div class="categories_left_line"> <label for="search_string"> Cauta in denumire/descriere: <input type="text" name="search_string" id="search_string" value="<?php echo getFilterValue("search_string", $active_filters); ?> " /> </label> </div> <!-- AICI VIN SI RESTU CAND OR FI --> <input type="submit" value="Aplica filtre" /> </form> </div>