根据值数组更新db字段

i need to run a sql query to do some database updates.

$members = "120,238,93,123,1";

and then i need to run a sql query like :

$DB->query("UPDATE " . DB_PREFIX . "members SET lastvisit=$lastvisit WHERE member_id=$members_id");

what i am trying to do is to run the db update for each of the members id`s that i specify at the start of my file. guess i need to explode the $members and do a for clause or something but not sure how its supposed to be

This should work:

$DB->query("UPDATE " . DB_PREFIX . "members SET lastvisit=$lastvisit WHERE member_id IN (120,238,93,123,1) ");