title: MySQL query updating depending on $_POST values
body: <p>I am having trouble thinking out a good way to update my query depending on user $_POST values. Basically I have user management search button, where site administrator can search for his sites users. In my example:</p>
  
  <pre><code>&lt;div id="website_user_management_search_left"&gt;
  &lt;div id="website_user_management_search_left_leftside"&gt;
      &lt;p&gt;Name:&lt;/p&gt;
      &lt;p&gt;Surname:&lt;/p&gt;
      &lt;p&gt;Telephone:&lt;/p&gt;
      &lt;p&gt;Group:&lt;/p&gt;
      &lt;p&gt;Discount group:&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="website_user_management_search_left_rightside"&gt;
      &lt;input type="text" name="#" value="#" id="userSearch_name"&gt;
      &lt;input type="text" name="#" value="#" id="userSearch_surname"&gt;
      &lt;input type="text" name="#" value="#"&gt;
      &lt;input type="text" name="#" value="#"&gt;
      &lt;input type="text" name="#" value="#"&gt;
      &lt;input type="submit" id="button_adminUserSearch" value="Search"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Then after pressing "Search" button AJAX sends request to retrieve results, but how can I handle this dynamic query?
  For example - if user just presses "Search" query would look like:</p>
  
  <pre><code>mysqli_query($dbconnect,"SELECT * FROM accounts");
  </code></pre>
  
  <p>For example - if user specifys $_POST["name"] value, query would look like:</p>
  
  <pre><code>mysqli_query($dbconnect,"SELECT * FROM accounts WHERE name='".$_POST["name"]."'");
  </code></pre>
  
  <p>Problem is - how can I efficiently handle this kind of query? It would be dumb to check which values is "isSet" and then make tons of query cases.
  I hope you understood my problem and can help out with it, because it`s kinda hard to explain it.</p>