dimanche 5 avril 2015

Shorter way of writing multiple conditions from checkbox selections in php

I'm sending information from an html form into a php page where I am checking the information against a mysql database. Right now there are 5 checkboxes plus other variables in the form(searchbar, radiobuttons, etc). Is there a way to write the conditions without having to have a specific if statement for each path? Otherwise I have to write each specific path, and thats a lot of typing :/


Right now it would look something like:



if($orderBy == "price")
{
if($searchBy == "begin")
{
if($_POST["gameType"] == "RTS")
{
$sql = "select * from gametbl where gme_title like '$title%' and where gme_type = 'RTS' ORDER BY gme_price DESC";
}
}


and for all the conditions, thats going to take way to long. Is there a better way of doing this?





Aucun commentaire:

Enregistrer un commentaire