title: Mysql search function
body: <p>I am trying to setup a search function where i can either type in what i want or i can select it from a drop down menu, however when the fields are blank i want it to show everything.</p>
  
  <p>Right now when i search for something it will work however when the fields are blank it does not show anything at all. I am using prepare and bind_params to setup the mysql query which is why it is making it difficult to setup because if the variable is empty im not sure how to easily remove that section of the query and also change the amount of variables that are being binded to the query. Here is the query</p>
  
  <pre><code>$stmt = $conn-&gt;prepare("SELECT * FROM re_tblcombinationlist WHERE active != ? AND ModifierKey = ? AND (LootItem1Key = ? OR LootItem2Key = ? ) ORDER BY ReportedOn DESC LIMIT ? , ?");
  $stmt-&gt;bind_param("isssii", $i = 0, $modifier, $lootsearch, $lootsearch, $limits, $max);
  $recent1 = infoo($stmt);
  </code></pre>
  
  <p>I tried to solve it by adding this if then statement but it didnt change anything</p>
  
  <pre><code>if(!isset($_POST["modifier"])){
  $modifier = '';
  }else{
  $modifier = clean($_POST["modifier"]);
  }
  
  if(!isset($_POST["lootsearch"])){
  $lootsearch = '';
  }else{
  $lootsearch = clean($_POST["lootsearch"]);
  }
  </code></pre>
  
  <p>Basically if modifier or lootsearch are empty i dont want that section to be in the mysql query, which is easy to do however it then makes it very difficult to deal with the amount of variables to bind so i was trying to find a way to make it search everything if the variable is empty.</p>
  
  <p>Thanks</p>