/    Sign up×
Community /Pin to ProfileBookmark

loop problems

ok i want this statement that only display data if the search criteria match

[code=php]

}
$query = “SELECT * FROM `business_info` WHERE `make`=’make’ AND `type`=’type’ AND `Categories` LIKE ‘%”.$Categories.”%'”;
$result = mysql_query($query) or die (mysql_error());
$num_result = mysql_num_rows($result);
echo “<table>”;
if($num_result <= 0){
echo(“No Results found.”);
exit;
}

[/code]

this is my display

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 19.2006 — So, what is your question/problem?
Copy linkTweet thisAlerts:
@NightShift58Dec 19.2006 — I think your post got cutoff somewhere. Can you resubmit with the rest of the post?
Copy linkTweet thisAlerts:
@franknuauthorDec 20.2006 — ok, i only posted the part that needs work

basicly what i need is this

if ( make==make and type==type)

SELECT * FROM business_info WHERE make='make' AND type='type' AND Categories LIKE

so they all have to match if i have a Caterories but it doesnt match with the make and type them it wont display anything
Copy linkTweet thisAlerts:
@NightShift58Dec 20.2006 — I'm not getting the point.

Why do you want to apply an IF condition in the script and then again in the SQL query?
Copy linkTweet thisAlerts:
@bokehDec 20.2006 — [code=php]$query =
"SELECT * ".
"FROM business_info ".
"WHERE make='make' ".
"AND type='type'".
((!empty($Categories)) ? " AND Categories LIKE '%".$Categories."%'":'');[/code]
×

Success!

Help @franknu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...