title: Insert into MYSQL based on If else statement
body: <p>Hello guys I have this simple MYSQL statement which I can't seem to insert into database properly..</p>
  
  <pre><code>if($item_cat == "Hardware") {
      $item_filter = "2";
      $item_filter = trim($_POST['item_filter']);
      $item_filter = strip_tags($item_filter);
      $item_filter = htmlspecialchars($item_filter);
   } elseif($item_cat == "Software") {
      $item_filter = "3";
      $item_filter = trim($_POST['item_filter']);
      $item_filter = strip_tags($item_filter);
      $item_filter = htmlspecialchars($item_filter);
   }
  
   $query = "INSERT INTO items(item_cat , item_filter) VALUES('$item_cat','$item_filter')";
  </code></pre>
  
  <p>The concept I want to achieve is based on the user's selection of a select input (hardware or software) the item_filter is added based on this selection. When I try and run this code it tells me <code>item_filter is undefined.</code></p>
  
  <p>Any help or another approach to solve this would be greatly appreciated.</p>