I have been looking at using IN(array) and I have seen a lot of examples here such as This example and this but for some reason my query does not return anything. I am making an android application for job advertising, I have a table with all the jobs in my database and all jobs have a typewhich can be any of these "Advert","Consultancy","Freelance","Full Time","Internship","Part Time","Temporary"
. On the android side user selects which job type/s
they wish to view and I compile a JSONArray and convert it to a string using toString()
then send it to the server side, the typical array looks like
["Advert","Consultancy","Freelance","Full Time","Internship","Part Time","Temporary"]
When received its converted to a php
array
`$types = json_decode('["Advert","Consultancy","Freelance","Full Time","Internship","Part Time","Temporary"]', TRUE);`
then finally
$match_list = join(",", $types);
$result = $this->conn->prepare("SELECT j.id, u.username, j.title, j.description,j.category, j.type, j.submissionDeadline, j.link, j.datecreated FROM job_tb j JOIN user_tb u ON u.id = j.userFk WHERE DATE(j.submissionDeadline) > DATE(NOW()) AND j.type IN (?) ORDER BY j.datecreated DESC");
$result->bind_param("s", $match_list);
$result->execute();
$response["jobs"] = array();
$result->bind_result($id, $username, $title, $description, $category, $type, $submissionDeadline, $link, $datecreated);
while($row = $result->fetch())
{
$job = array();
$job["id"] = $id;
$job["username"] = $username;
$job["title"] = $title;
$job["description"] = $description;
$job["category"] = $category;
$job["type"] = $type;
$job["submissionDeadline"] = $submissionDeadline;
$job["link"] = $link;
$job["dateCreated"] = $datecreated;
$response["jobs"][] = $job;
}
Unfortunately nothing is returned but when I pass a single job type item array like ["Part Time"]
it returns all jobs of type Part Time
so what could be the problem?