我需要多个复选框搜索才能工作,但我被卡住了。表格没问题,但我不知道如何进行查询。有人请帮助我吗?
形式 :
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="Loft"><div class="lbl">Loft</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="Studio"><div class="lbl">Studio</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="2 pieces"><div class="lbl">2 pièces</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="3 pieces"><div class="lbl">3 pièces</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="4 pieces"><div class="lbl">4 pièces</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="5 pieces"><div class="lbl">5 pièces</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="6 pieces et +"><div class="lbl">6 pièces et +</div>
<input id="propertytype" class="noborder" type="checkbox" name="propertytype2[]" value="Proprietes, Hotels particuliers"><div class="lbl">Propriétés, Hôtels particuliers</div>
询问 :
$search_propertytype = "";
if (isset($_POST['propertytype2'])) {
$search_propertytype = trim($_POST['propertytype2']);
}
if (get_option('wp_search_propertytype') == "Yes") {
if($search_propertytype != '')
{
$search_propertytype = trim($search_propertytype);
$query ="SELECT p.* FROM $wpdb->posts p, $wpdb->postmeta p1 WHERE p.ID = p1.post_id AND (p1.meta_key='propertytype_value' AND p1.meta_value='$search_propertytype' OR p1.meta_key='propertytype2_value' AND p1.meta_value='$search_propertytype')";
$sptt = getIds( $query );
$_ids = ( !empty($sptt) ? ( !empty($_ids) ? array_intersect( $_ids, $sptt) : "" ) : "" );
}
}