UPDATE!! My code is actually valid to run. The original question is below. If you are still curious please read the question and then back to read my update.
My bad, the db actually can get updated successfully after the code runs. I accidentally set the datatype in the table as INT but my initial intention, varchar.
But from HenryDev's answer I managed to find the acquired array by post method in php becomes STRING type but array type. I used
$cameArray = $_POST['cameArray'];
echo gettype($cameArray);
to output "string" on my screen, so implode would not work oh that(see the discussions on HenryDev's answer).
However his answer will work as a charm if you set up an array in PHP and implode it, it will give you back a "string type" of your array!
UPDATE!! My code is actually valid to run. The original question is below. If you are still curious please read the question and then back to read my update.
Here is my original question
So I have a very basic question but the tutorials and answers I found online are kinda complicated for my situation.
I have a JS array like
var sentArray = ['1','2','3'];
I want to insert this array into the database as one field of a table. I use ajax to send this array to PHP and then execute the query in PHP. For instance,
$cameArray = $_POST['cameArray']; //then $cameArray is sentArray
mysqli_query($con, "INSERT INTO thisTable (arrayField) VALUES ($cameArray)");
And then I want the value in the database shown as "1, 2, 3", but the problem is the value in the database is simply shown as a single "2". The type in table is varchar.
No any JSON object involved just pure text. How could I do that? Thanks!