Jump to content

[SOLVED] is this possible with a foreach


graham23s

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/68574-solved-is-this-possible-with-a-foreach/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.