Home > Archive > PHP Programming > May 2005 > search criteria
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| overflo 2005-05-27, 3:57 pm |
| 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.
| |
| lesperancer@natpro.com 2005-05-27, 3:57 pm |
| 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...
|
|
|
|
|