I have an usual search form using HTML that will be extract the data from mysql (the connection is using PHP and mysqli). The function works well in searching 1 value, but I want to make user can search more than 1 value that will be separated by comma (,).

For example:
[![Searching 1 value works well](https://i.stack.imgur.com/wro0M.png)](https://i.stack.imgur.com/wro0M.png)
Searching 1 value works well.

But I want to search 2 or more values inside the search box, like: *42-7278954,53-1217544,07-2517487,...*

I hope user can input something like in the pic below and the **result will have 2 rows** -->
CN\_no **42-7278954** and **53-1217544**:

[![enter image description here](https://i.stack.imgur.com/KTk0m.png)](https://i.stack.imgur.com/KTk0m.png)

The query I have so far is:

```
$sql = "SELECT * FROM mock_data WHERE CN_no IN ('{$CN_no}') OR doc_no IN ('{$doc_no}')";

```

*Notes: CN\_no is "Shipment Code" and doc\_no is "Reference No"*

But well... it's obviously give me an error because of the incorrect syntax. 

Please help me to revise it. Thank you.

======== update query based on vp\_arth's answer ========

```
$cn = explode(',', $CN_no);
$incn = str_repeat('?, ', count($cn)-1).'?';
$doc = explode(',', $doc_no);
$indoc = str_repeat('?, ', count($doc)-1).'?';

$query = "SELECT * FROM mock_data WHERE CN_no IN ({$incn}) or doc_no IN ({$indoc})";
$result = $conn->query($query , array_merge($incn, $indoc));

```

But it give me an [error](https://anakpanti.com/ab-cargo/controllers_searchshipment/)