I have an html table that loads everything in a mySQL database table. I have dropdowns that relate to columns of that mySQL table - when the user selects one of the dropdowns it uses AJAX to querry the database.I need to figure out how to build the querry dynamically because sometimes the dropdowns will be empty (i.e. they don't want to filter by that column).What is the best way to do this?Currently I have something like this:\[code\] $stationFilter = $_GET['station']; $verticalFilter = $_GET['vertical']; $creativeFilter = $_GET['creative']; $weekFilter = $_GET['week']; $result = mysql_query("SELECT * FROM $tableName WHERE STATION_NETWORK = '$stationFilter' AND VERTICAL = '$verticalFilter' AND CREATIVE = '$creativeFilter' AND WK = '$weekFilter'"); $data = http://stackoverflow.com/questions/15794179/array(); while ($row = mysql_fetch_row($result) ) { $data[] = $row; } $finalarray['rowdata'] = $data;\[/code\]Which you can imagine doesn't work because if any of those fields are empty - the querry fails (or returns nothing, rather).Obviously creating such a 'static' querry like that really makes it difficult if certain variables are empty.What is the best way to dynamically create that querry so that it only enters the ones that are not empty get added to the querry so it can succesfully complete and display the appropriate data?