how to insert multiple json data into mysql database in php code example

Example: how to insert multiple json data into mysql database in php

<?php 

$josndata = '{
"Customer":{ "name":"Jonny", "country":"CANADA", "ContactNo":524587777 },
"Student":{ "name":"Gussy", "country":"USA", "ContactNo":9856452100}
}';  

// Database connection
$conn = new mysqli('localhost', 'username', 'password', 'databasename');

// Insert data Query
$sql = "INSERT INTO student_table ( name, jsondata )
VALUES ('Multidata', '$josndata')";

if ($conn->query($sql) === TRUE) {
  echo "Insert your Multiple JSON record successfully";
} 
?>

Tags:

Php Example