Help is appreciated............

:slight_smile: All!

I am stuck at the following php function. However, this function works well only when using either ‘AND’ or ‘OR’… but What I want here as in the below function but I don’t know how can it be done. Any help is appreciated… :-* Doing this mysql query will return the result what I want and is correct according to the query… :smiley:

[php]
function sort_multiple_key_feature_2($key_feature)
{
$spec=explode(’/’,$key_feature);
//print_r($spec);die();
//$spec=$_REQUEST[‘chk_obj3’];
$sql = ‘’;
// there is at least one checkbox selected
if (count($spec) > 0) {

$sql .="select count(product_id) from t_audio_detail where ";

for ($i=0;$i<count($spec);$i++) {
if($spec[$i]==‘Hi-Fi System’ or $spec[$i]==‘Portable’){
$sql .=“type=’”.$spec[$i]."’ OR “; }
if($spec[$i]==‘usb_port’ or $spec[$i]==‘component_video_output’){
$sql .=$spec[$i].”=‘Yes’ AND “; }
if($spec[$i]==‘mp3disc_compatible’ or $spec[$i]==‘wma_compatible’ or $spec[$i]==‘vcd_compatible’ or $spec[$i]==‘dvd_compatible’ or $spec[$i]==‘divxdisc_compatible’){
$sql .=$spec[$i].”=‘Yes’ AND “; }
if($spec[$i]==’—’ or $spec[$i]==‘1’ or $spec[$i]==‘3’ or $spec[$i]==‘5’){
$sql .=“number_cds=’”.$spec[$i].”’ OR “; }
if($spec[$i]==‘2 spk’ or $spec[$i]==‘3 spk’ or $spec[$i]==‘4 spk’ or $spec[$i]==‘5 spk’ or $spec[$i]==‘6 spk’ or $spec[$i]==‘7 spk’){
$sql .=“number_speaker=’”.$spec[$i].”’ OR "; }
} // end “for” loop
}
echo rtrim($sql,‘OR’);
}

[/php]

:slight_smile: :wink: :smiley: ;D 8) :-* He BTW I have done it…My problem is solved… just a string handling voila!..

Sponsor our Newsletter | Privacy Policy | Terms of Service