graham23s Posted September 9, 2007 Share Posted September 9, 2007 Hi Guys, i was wondering if this is possible: when i do a foreach on a file, i get the data i want back perfecly i.e: file1 file2 file3 when i goto store it in mysql it only stores the first file (i know its because the insert query isnt inside the loop) but is there a way i can store the files in an array inside the loop , then store the array variable inside mysql, then maybe explode the files individually when i retrieve them? kind of like: $array = array(file1,file2,file3); hope that males sense lol cheers guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/68574-solved-is-this-possible-with-a-foreach/ Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2007 Share Posted September 9, 2007 you could implode the file names with an unusual characters, probably a pipe | them explode them when you pull them out of MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/68574-solved-is-this-possible-with-a-foreach/#findComment-344740 Share on other sites More sharing options...
GingerRobot Posted September 9, 2007 Share Posted September 9, 2007 You can store arrays in a field in mysql, with the serialize() function. You could then use unserialize() function on the data when you retrieve it. However, you are likey to be better off not storing an array, and storing each element separately. By storing an array in a database, you are removing most of the power of a database. You would no longer be able to perform searches,sorts or any other of the many database fuctions on the data. Quote Link to comment https://forums.phpfreaks.com/topic/68574-solved-is-this-possible-with-a-foreach/#findComment-344764 Share on other sites More sharing options...
graham23s Posted September 9, 2007 Author Share Posted September 9, 2007 thanks for the input guys its appreciated gonna tinker with a few bits of code. Graham Quote Link to comment https://forums.phpfreaks.com/topic/68574-solved-is-this-possible-with-a-foreach/#findComment-344812 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.