Can I bind multiple values as a single parameter using MYSQLI and PHP?

lerenard1968

New Member
Imagine I have the following SQL query:\[code\]SELECT id,name FROM user WHERE id IN ('id1','id2','id3')\[/code\]Now imagine I need the array of ids to be supplied by PHP. So I have something like this:\[code\]$idList = array('id1','id2','id3');$query = "SELECT id,name FROM user WHERE id IN (?)";$stmt = $db->prepare($query);$stmt->bind_param(/*Something*/);\[/code\]What can I replace \[code\]/*Something*/\[/code\] with to get the same results as the original query? Or do I need to put in 3 question marks in the query format? The only reason I don't want to do that is because the number of question marks is variable, so I would have to build the query string manually.
 
Back
Top