I know I do many, many things wrong in this, but I don’t have a clue how to fix this (except making many separate queries.
mysql_query( 'SELECT *
FROM opdracht
where'. if(isset($opleiding))
{
'opleiding = "'.$opleiding.'" and'
}
if(isset($duur))
{
'duur = "'.$duur.'" and '
}
if(isset($type))
{
'type = "'.$type.'" and'
}
' gevuld ="nee";');
basically, what I’m trying to do is making a query which statements depends on the variables.
This code doesn’t work, but I can’t think of a way to make it work.
Help?
Set them outside, and then use them inside the query. Also, you should be checking for errors. (I don’t remember how to do so in
mysql_query()as it is very old and I don’t use it. If someone knows please edit my answer)