By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,403 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,403 IT Pros & Developers. It's quick & easy.

search criteria

P: n/a
I'm new to PHP & MySQL. I want to be able to process a form with 4
input fields according to how many fields are filled out. If only one
is filled, it searches on that, if two it searches accordingly etc. I
have all the select statements for each instance working I just don't
know the best way to call them. Would it be an if else statement (
perhaps if(!isset???) that would call each script or is there a better
way. Any help would be appreciated.

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
so you input say, name, address, phone and email and you only want the
WHERE clause to include the entered data ?

..
..

$needAnd = 0;
if ($name != '') {
$strsql .= " Name = '" . $name . "'";
$needAnd = 1;
}

if ($address != '') {
$strsql .= ($needAnd == 1 ? " AND " : "") ." Address = '" . $address
.. "'";
$needAnd = 1;
}

and so on...

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.