PHP Json array decode in php and inserting mysql -


this question has answer here:

"sci-6":{"quantity":11,"id":"sci-6","price":15,"name":"notebooks"}, "sci-7":{"quantity":1,"id":"sci-7","price":10,"name":"posters"}, "sci-8":{"quantity":2,"id":"sci-8","price":15,"name":"pen"}, "sci-9":{"quantity":4,"id":"sci-9","price":100,"name":"charger"}, "sci-10":{"quantity":1,"id":"sci-10","price":10.25,"name":"news paper"} 

please me decode variables , insert values mysql using php

$data = '{"sci-6":{"quantity":11,"id":"sci-6","price":15,"name":"notebooks"},"sci-7":{"quantity":1,"id":"sci-7","price":10,"name":"posters"},"sci-8":{"quantity":2,"id":"sci-8","price":15,"name":"pen"},"sci-9":{"quantity":4,"id":"sci-9","price":100,"name":"charger"},"sci-10":{"quantity":1,"id":"sci-10","price":10.25,"name":"news paper"}}';  $json_data=json_decode($data); foreach($json_data $json_value) {      mysql_query("insert yourtable (quantity, id, price, name) values ('".$json_value->quantity."','".$json_value->id."','".$json_value->price."','".$json_value->name."')");  } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -