How to store multidimensional array in database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rahulephp
Forum Commoner
Posts: 28
Joined: Mon Oct 05, 2009 11:05 am

How to store multidimensional array in database?

Post by rahulephp »

Hi there,

can you please help me?

i have data in array and i want to insert it in a single table.
structure of table and array to be store is shown below:

Please let me know how to store this array in database?

Database Structure:
Image

array-structure
Image

database-Browse
Image

Let me know any solution for this?
Thanks in anticipation
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: How to store multidimensional array in database?

Post by JNettles »

I haven't actually tried but would JSON work on this?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to store multidimensional array in database?

Post by AbraCadaver »

It would probably be easier and make more sense if you changed your form so that the arrays look like this:

Code: Select all

Array
(
    [0] => Array
        (
            [temp_property_name] => x
            [temp_property_add] => x
            // etc...
        )
        
    [1] => Array
        (
            [temp_property_name] => y
            [temp_property_add] => y
            // etc...
        )
 
)
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply