Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.