Title. I just started to learn PHP, the foundation is not good, Baidu for a long time can not be achieved, hoping to give examples. The JSON data is stitched together to get
T
1.php does not write
Reply to discussion (solution)
The format returned by the general Web site is a JSON post submission that is written as "Shop=%e5%95%86%e5%ba%971&goods=%e8%b4%a7%e7%89%a91& ..." (URL encoding)
php to get $shop = $_post[' shop '];
inserting into a database
First of all, your fields were wrongly written.
It is unlikely to use JS code to assemble JSON strings, or at least to use the Ajax.stringify method to convert
To write (the clear point of a break)
var fields = [ {"Shop": "Store 1", "goods\": "Goods 1", "Price": "10 Yuan"}, {"Shop": "Store 2", "goods": "Goods 2", "Price": "11 Yuan"},< c2/>{"Shop": "Store 3", "goods": "Goods 3", "Price": "13 Yuan"}];
Upon submission
Data: {Fields:fields},
PHP side $_post[' Fields ' is an array of commits
The format returned by the general Web site is a JSON post submission that is written as "Shop=%e5%95%86%e5%ba%971&goods=%e8%b4%a7%e7%89%a91& ..." (URL encoding)
php to get $shop = $_post[' shop '];
inserting into a database
JSON array is to get the data of table splicing, no id,name and so do not know how to form this URL encoding
First of all, your fields were wrongly written.
It is unlikely to use JS code to assemble JSON strings, or at least to use the Ajax.stringify method to convert
To write (the clear point of a break)
var fields = [ {"Shop": "Store 1", "goods\": "Goods 1", "Price": "10 Yuan"}, {"Shop": "Store 2", "goods": "Goods 2", "Price": "11 Yuan"},< c2/>{"Shop": "Store 3", "goods": "Goods 3", "Price": "13 Yuan"}];
Upon submission
Data: {Fields:fields},
PHP side $_post[' Fields ' is an array of commits
How does PHP write, how to insert the received JSON array into the database?