Sunday, 15 September 2013

php - Insert Array values, multiple rows -



php - Insert Array values, multiple rows -

i'm trying record info on database. post looks this:

array ( [action] => 1000 [date_stat] => 07/02/2013 [date_final] => 07/02/2013 [product_id] => array ( [0] => 2 [1] => 6 [2] => 1 ) [conversion] => array ( [0] => 1,20 [1] => 1,00 [2] => 2,03 ) [valuemin] => array ( [0] => 2,00 [1] => 1,58 [2] => 2,70 ) [valuemax] => array ( [0] => 2,50 [1] => 1,98 [2] => 2,90 ) [valuemedio] => array ( [0] => 2,20 [1] => 1,68 [2] => 2,80 ) )

how can insert on database right way?

i'm not sure best way design tables , store information. i'm using create cost table starting date, final date , list products prices.

also i'm thinking best method. there 2 possibilities think about

date_start | date_end |product_id | valuemin | valuemax | valuemedio | conversion 02-02-2013 02-03-2013 1 1.00 2.00 3.00 4.00 02-02-2013 02-03-2013 2 1.00 2.00 3.00 4.20 02-02-2013 02-03-2013 3 1.00 2.00 2.00 4.40

or (using implode , putting values on same row)

date_start | date_end |product_id | valuemin | valuemax | valuemedio | conversion 02-02-2013 02-03-2013 1,2,3 1,1,1 2, 2,2 3,3,2 4, 4.3, 4.4

thanks lot!

choose alternative mentioned first. selecting rows become much easier if way.

to insert records, utilize simple prepared statement (php manual) , utilize for-loop.

php mysql

No comments:

Post a Comment