php - Mysql Select Code Doesn't work -
i have php/mysql select code doesn't return result have expected after execution of code. code: [select]
$sql="select *from advert ad_type = '%{$service}%' , ad_street_no '%{$location}%' or ad_street_name '%{$location}%' or ad_suburb '%{$location}%' or ad_postcode '%{$location}%' or ad_state '%{$location}%'";
the user search on location , type of service available using parameters street name,suburb, postcode and/or state in 1 textfield , select type of service dropdown menu. example : "select records table 'advert' type of service = 'e.g. hauling,digging,' located @ e.g. cardiff nsw". " that.
i have 2 records right on database : 1. service: hauling, location: cardiff nsw 2. service: digging , location: cardiff nsw
now problem is:
you search "hauling" service in "cardiff" , return 2 records (#1 , #2). search "digging" service in "cardiff", return 2 records (#1 , #2). search either of services in " cardiff nsw", return 0 results.
i got no idea on how fix this. please me guys. thank in advance. :( :( :(
best regards
first off, need brackets:
$sql="select *from advert ad_type '%{$service}%' , ( ad_street_no '%{$location}%' or ad_street_name '%{$location}%' or ad_suburb '%{$location}%' or ad_postcode '%{$location}%' or ad_state '%{$location}%'" );
that fix first case. need think you're providing : instance if provide town don't want include ad_type in query @ all.
Comments
Post a Comment