Friday 15 June 2012

php - storing array in a sql database -


I started meeting in arrays and did not get enough to work well. I am used to working with explosion / file functions, but although I make my life easier in this part of code. Here the function has been called:

  function save_event ($ event_items = NULL) {include 'connect.php'; $ Now = Date ("Y-M-DHH: I: S"); Include $ Sqla = "Event '(` event_items`, `event_entered`) values ​​(' $ event_items', '$ now')"; $ Resulta = mysqli_query ($ link, $ sqla); If (! $ Resulta) {echo '& lt; Br / & gt; There was an error while entering your data. Please try again later. & Lt; Br / & gt; '; } Else {echo 'is the variable to store:  this database value is: & lt; br / & gt; '; Print_r ($ line [' event_items']) ;}}}}   

This function prints:

  This is the variable to store: array ([0] => array ( [Item] = & gt; speaker [note] => [quantity] => 2 [value] => 200.00 [category] => audio) [1] => array ([item] = & Gt; wireless microphone [note] => levelier [volume] = & Gt; 3 [value] => 175.00 [Category] => Audio) This is the value of the database: PhpMyAdmin in the array   

I column event_items array .

Additional information: I have a table called Group, each group will have one or several orders (the second table of order name) and each The order will have one or more events (another table). Lastly, each event will have one or more items (each item, its contents Bond price, quantity, notes and Series), which are stored in a (or several) column in the event table.

You can sort your array with the serialize () function.

Example:

  in order ($ event_items);   

Presents a strong representation of the value.

It is useful to store or pass around the surrounding PHP values ​​without losing their type and structure.



No comments:

Post a Comment