Q:

How I can sort the data with array in php?

In postman,
I post the array like 

key => Image[] / value => 1
key => Image[] / value => 2
key => Image[] / value => 3

I want when I put an array which user's card images, receive the card's Idx and Name.
So I make query like this,
$query = "SELECT DISTINCT
                    Idx AS Idx, 
                    Name AS Name 
                    FROM Card
                    WHERE Card.Image IN ('$_POST[Image]')";

But, It receive no data.
So I remove '' so 
WHERE Card.Image IN ('$_POST[Image]')" 
=> WHERE Card.Image IN ($_POST[Image])";

Then return Unknown column 'Array' in 'where clause'
I don't know what is problem of this.
when I post array like /key name[]/value 1
I know it can receive $_POST[name].
How I can post array and receive of it.
Please help me.

A:

I hope Image column contains numbers.
Use implode() to correct your IN query
$string=$_POST['Image'];
$array= implode(',', $string);
$query = "SELECT DISTINCT Idx AS Idx, Name AS Name FROM Card WHERE Card.Image IN ($array)";

Note:-
1.Query will become:-SELECT DISTINCT Idx AS Idx, Name AS Name FROM Card WHERE Card.Image IN (1,2,3). Now it will execute fine.
2.Try to use prepared statements of mysqli_* or PDO to prevent your code from SQL-INJECTION. You current code is wide-open for it.

