schnell explination, wie Sie eine JSON-Datei lesen konnte und es in eine Tabelle in der Datenbank anhängen:
<?php
//connect to DB
$con = mysql_connect("username","password","") or die('Could not connect: ' . mysql_error());
mysql_select_db("product", $con);
//read the json file contents
$jsondata = file_get_contents('empdetails.json');
//convert json object to php associative array
$data = json_decode($jsondata, true);
//get the product details
$code = $data[code];
$name = $data[name];
//insert into mysql table
$sql = "INSERT INTO product(code, name) VALUES('$code', $name)"
if(!mysql_query($sql,$con))
{
die('Error : ' . mysql_error());
}
?>
dies ausreichen sollten Sie loslegen
Was haben Sie versucht? StackOverflow ist eine Website, die mit Code arbeitet und keinen Code für Sie schreibt. Check out [einige] (http://stackoverflow.com/questions/34848563/insert-nested-json-array-as-parameter-in-php-mysql-database) [andere] (http://stackoverflow.com/ Fragen/29937123/Insert-JSON-Daten-In-MySQL-Datenbank-mit-PHP) [Beispiele] (http://StackOverflow.com/Questions/26731046/How-To-Insert-JSon-array-into-mysql- Datenbank-mit-PHP). –
@ T.J.Crowder das ist JSON, er hat es nur nicht umgeben in Anführungszeichen – Grey
@ Luuk: Das oben genannte ist [nicht, was ich kommentiert] (http://stackoverflow.com/revisions/40106122/1). –