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! Quote 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? Quote 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. Quote 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) . ") ... Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.