Hello all,
I'm working on a PHP/MySQL project, and wanted to get some advise... I need to search a MySQL database based upon what is entered in about 7 different text input's... Last name, first name, phone number, etc.... Is there a good way to modify the query depending on if the text inputs are blank or not? I was going to do something like
$query = "SELECT * FROM table WHERE col1 = '$value1' AND col2 = '$value2';
etc etc...
But what if they don't put anything in the text input with the name value2? so it turns into
$query = "SELECT * FROM table WHERE col1 = '$value1' AND col2 = '';
Is there some efficient way to write an if/else clause that detects which input tags are blank, and changes the SELECT clause accordingly? Or do I just need to write a huge if/else that takes into account the different combinations of inputs...
Thanks,
Brad