I was wondering if it is possible to put an if statement inside a mysql statement. I'd like to do a check for some defined variables inside my query. I was hoping to do something like this but this of course doesn't work...
query = "SELECT * ".
"FROM table ".
"where id = 1 "
if(isset($_GET[variable1])){
."and variable1 = $_GET[variable1] "}
if(isset($_GET[variable2])){
."and variable2 = $_GET[variable2] "};
Any suggestions how I could get something like this to work? Thanks!
query = "SELECT * ".
"FROM table ".
"where id = 1 "
if(isset($_GET[variable1])){
."and variable1 = $_GET[variable1] "}
if(isset($_GET[variable2])){
."and variable2 = $_GET[variable2] "};
Any suggestions how I could get something like this to work? Thanks!