You could create a comma separated list of the ids, with implode if they're in an array then make your query use the IN caluse
$allIDs = implode(',', $ids);
$q = "SELECT * FROM table WHERE id IN ($allIDs)";
Don't worry about the size of the query string, it can be about 16 Meg or something in a standard install (I think).