I have an array which populated by a cookie. The length differ each time. The values that contains are ids taht I want to select from a database. I know that I can use something like below to retrieve multiple rows with specific ids:
$query = "SELECT game_id,thumb,title,rating,instructions FROM games WHERE game_id IN ('111','110')";
My question is, how can I retrieve from the database the ids of the array $favGames ? I found in another question the following: WHERE id IN (' . implode(',', $ids) . ')'; but it doesn’t seems to works for me. What other options do I have?
You’ll need something like this:
If you don’t have the extra single quotes in the call to implode, your query would look like:
Notice the missing quotes? That’s what’s causing your error.