按复选框搜索供应商并选择选项

时间:2013-02-14 11:53:25

标签: php jquery mysql database search

我有这样的供应商列表(如下图所示)

enter image description here

http://www.pkbazaar.com/classifieds-house-real-state-sale-buy-lahore-karachi.php

现在我可以通过“提供的服务”,“预算”和“星级评分”来搜索供应商吗?

我正在使用搜索查询,就像这样

$query = mysql_query("SELECT vendor.* FROM vendor
LEFT JOIN  items_ratings ON vendor.vendor_id=items_ratings.vender_id
LEFT JOIN  services ON vendor.vendor_id=services.vender_id
WHERE vendor.price >= ".$_POST['priceA']." AND vendor.price <= ".$_POST['priceB']." AND (SELECT AVG( items_ratings.rating )
FROM `items_ratings`
WHERE vendor.vendor_id = items_ratings.vender_id
AND (SELECT service_name
FROM `services`
WHERE vendor.vendor_id = services.vender_id
AND vendor.vendor_type = '".trim($_POST['vendor_type'])."') >= ".$_POST['rating']." AND vendor.vendor_type= '".trim($_POST['vendor_type'])." AND services.vendor_type= '".trim($_POST['service_name'])."' GROUP BY vendor.vendor_id");

我的其他代码就像这样

JS代码

function search_func()
{
var priceA = $('select#valueA').val();
var priceB = $('select#valueB').val();
var guestA = $('select#g_valueA').val();
var guestB = $('select#g_valueB').val();
var rating = $('select#rating').val();
var facility = $('#service_name').val();
var vander_type = $('#vander_type').val();
var dataString = 'priceA='+priceA+'&priceB='+priceB+'&rating='+rating+'&service_name='+facilities+'&vendor_type='+vander_type;

$.ajax({
          type: "POST",
          url: "ajax_pages.php?act=get_list",
          data: dataString,
          success: function(response) { $('#listing_div').html(response); }

     });
}
</script>

我将 PHP mysql数据库一起使用 .................................................. ............

注意:当我从查询LEFT JOIN services ON vendor.vendor_id=services.vender_id中移除此代码时,按预算和星级评分搜索工作正常 和

FROM items_ratings
WHERE vendor.vendor_id = items_ratings.vender_id
AND (SELECT service_name
FROM `services`

并从JS中删除此代码

var service_name = $('#service_name').val();

'&service_name='+service_name+

0 个答案:

没有答案