but it's totally impractical, not to mention ugly. any good solution out there?$form_username = 'bleah'; $form_name = 'joejoe'; $SQL = "SELECT FROM table WHERE"; if ($form_username) { $SQL .= "username = $form_username AND "; } if ($form_password) { $SQL .= "password = $form_password AND "; } if ($form_name) { $SQL .= "name = $form_name AND "; } $SQL =~ s/\sAND\s$//; #exists if not everything is filled in print $SQL;
In reply to mysql search statement by Parham
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |