CSkovholm Posted April 25, 2010 Share Posted April 25, 2010 Hey guys I have an array with 3 ids. 20, 13 and 1. I now want to create a sql query, that uses the "WHERE id IN ()".. But how do i store the array, into the sql query? Something like "SELECT * FROM blabla WHERE id IN (".$array.")", however, i know you have to loop trough the array to output the values.. But how is this done? Thanks! Link to comment https://forums.phpfreaks.com/topic/199689-looping-trough-an-array-for-a-sql-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 25, 2010 Share Posted April 25, 2010 You have an existing thread for this exact same issue. Why start another thread? Link to comment https://forums.phpfreaks.com/topic/199689-looping-trough-an-array-for-a-sql-query/#findComment-1048086 Share on other sites More sharing options...
CSkovholm Posted April 25, 2010 Author Share Posted April 25, 2010 I don't.. The previous thread was which sql function is used to retrieve multiple ids. This one is about how to use this function together with an array. And i missed the location of my thread, so i've started a new. Link to comment https://forums.phpfreaks.com/topic/199689-looping-trough-an-array-for-a-sql-query/#findComment-1048089 Share on other sites More sharing options...
ToonMariner Posted April 25, 2010 Share Posted April 25, 2010 where id IN (" . explode(',',$array) . ") ... Link to comment https://forums.phpfreaks.com/topic/199689-looping-trough-an-array-for-a-sql-query/#findComment-1048116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.