0

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')) ";  
        }
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by futhonguy
0

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.

0

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!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.