Hi,

I tried to work this query out for a while but till now i still couldn't find what actually went wrong.
This search query has 2 search query option.

1) wildcard text search box
2) drop down list option

A user can either choose to search by (1) or (2) individually or both (1) and (2) to filter out even more. Howevery this search query can only serach individually but not both at the same time.

Can anyone able to help me out??

Cheers

if (trim($val_d) != '' or  trim($val_sub) != ''){ 

    $sql = "SELECT * 
	FROM wsdevice "; 
			
    if (trim($val_d) != ''){  
                  $sql .= " WHERE wsdevice_num like '%$val_d%'";   } 

    else if (trim($val_sub) != ''){ 
                   $sql .= " WHERE wsdevice_subconid = '$val_sub'"; 
        } 
    else  { 
                  $sql .= " WHERE ((wsdevice_num like '%$val_d%' )and (wsdevice_subconid = '$val_sub')) ";  
        }

because when you are giving both, first two statements also comes true and i never come in else part. Make your condition as if the both conditions are true in very first IF case and then single single in next two. remove else part. Hope you understand what i mean.

because when you are giving both, first two statements also comes true and i never come in else part. Make your condition as if the both conditions are true in very first IF case and then single single in next two. remove else part. Hope you understand what i mean.

BINGO!!!.. yea.. got it working now..

Cheers mate!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.