newb Posted November 22, 2011 Share Posted November 22, 2011 How can i convert an array of results to a single comma separated string so that I can run it through an SQL query? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2011 Share Posted November 22, 2011 implode Quote Link to comment Share on other sites More sharing options...
newb Posted November 22, 2011 Author Share Posted November 22, 2011 K thanks. Quote Link to comment Share on other sites More sharing options...
newb Posted November 22, 2011 Author Share Posted November 22, 2011 this worked better: foreach ($maintypes as $type) { $wheretype .= "'$type'"; } $wheretype = str_replace("''", "', '", $wheretype); $typesetting = @mysql_query("SELECT batch, quantity FROM batches WHERE type NOT IN ($wheretype) ORDER BY batch"); Quote Link to comment Share on other sites More sharing options...
Fadion Posted November 22, 2011 Share Posted November 22, 2011 Hmm, you sure that works better? <?php $arr = array('some', 'comma', 'seperated', 'values'); $csv = "'" . implode("', '", $arr) . "'"; echo $csv; ?> Quote Link to comment 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.