php - select rows depending on an array values -
i have array populated cookie. length differ each time. values contains ids taht want select database. know can use below retrieve multiple rows specific ids:
$query = "select game_id,thumb,title,rating,instructions games game_id in ('111','110')";
my question is, how can retrieve database ids of array $favgames
? found in question following: where id in (' . implode(',', $ids) . ')';
doesn't seems works me. other options have?
you'll need this:
$query = "select game_id,thumb,title,rating,instructions games game_id in ('" . implode("','", $favgames) ."')";
if don't have single quotes in call implode, query like:
select game_id,thumb,title,rating,instructions games game_id in ('111,110')
notice missing quotes? that's what's causing error.
Comments
Post a Comment