Search one of the field data Php / Mysql
<p><strong>Image 1</strong>
<a href="https://i.stack.imgur.com/Z1xv0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z1xv0.png" alt="enter image description here"></a></p>

<p><strong>Image 2</strong>
<a href="https://i.stack.imgur.com/55TOM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/55TOM.png" alt="enter image description here"></a></p>

<p>I am working with my search button and i want to search one of my text input in my database. If I search in specific data like filling up the 3 columns is working. But when I am gonna search one by one data , all data is shown. <strong>For example</strong> I only search for the "accounting department" then accounting department should all appear, but when i do it the other department is shown. if I only click for selected date , all the dates are appeared. Search only for id is working but for department and date are not.</p>

<p>Here's my html code: What if I only choose to search the Department then it should be appear the matching records as well as date.</p>

<pre><code>&lt;form name="searchitem" method="POST"&gt;
    &lt;input type="text" name="searchid"&gt; 
    Department : &lt;select name="department"&gt;

    &lt;option&gt;Select Department&lt;/option&gt;
    &lt;option value="MIS"&gt;MIS&lt;/option&gt;
    &lt;option value="ACCOUNTING"&gt;ACCOUNTING&lt;/option&gt;
    &lt;option value="CNC"&gt;CNC&lt;/option&gt;
    &lt;option value="CONCESSION"&gt;CONCESSION&lt;/option&gt;
    &lt;option value="INVENTORY"&gt;INVENTORY&lt;/option&gt;
    &lt;option value="HR"&gt;HR&lt;/option&gt;
    &lt;option value="WAREHOUSE"&gt;WAREHOUSE&lt;/option&gt;
    &lt;option value="SALES &amp; MARKETING"&gt;SALES &amp; MARKETING&lt;/option&gt;
&lt;/select&gt;

Date Added : &lt;input type="text" id = "datepicker" name="dateadd"&gt;&lt;br&gt;&lt;br&gt;        
&lt;input type="submit" name="submit" value="Search"&gt;
</code></pre>

<p>My <code>Php/Mysql</code> Code: I don't know what's wrong with the logic here: This should be working. Displaying output when only choose to search one field and when I run it, all data are displayed. I know you can help me with this.  </p>

<pre><code>$sql = "SELECT * FROM item_tb WHERE id like '%".$searchid."%' and department like '%".$department."%' and dateadd like '%".$dateadd."%' or id  like '%".$searchid."%' or   department like '%".$department."%' or date add like '%".$dateadd."%'";
$result = $conn-&gt;query($sql);
</code></pre>