Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Array in database

Hello,

Is there a way to upload an array to myslq database.

2 Answers

Kritian,

Usually if an array is important enough to store in mysql, you are going to also want to be able to manipulate the data stored. Like sort it, search it, modify it... Ect

I would suggest not storing it as an array, but break it down into meaningful tables.

You can easily loop thru your arrays and send over data to mysql.

Then when you want the data back, just rebuild your arrays the same way.

Thanks you both for the answers. I realy think it is better if i split my array into columns as Jeremy suggested.

Yes, this is possible. You can take a look at the following PHP functions:

Keep in mind that it is not always the best solution to store an array in the database, but sometimes it's necessary.

Hope this helps.