how to insert multiple json data into mysql database in php

Solutions on MaxInterview for how to insert multiple json data into mysql database in php by the best coders in the world

showing results for - "how to insert multiple json data into mysql database in php"
Jazmín
02 Jun 2017
1<?php 
2
3$josndata = '{
4"Customer":{ "name":"Jonny", "country":"CANADA", "ContactNo":524587777 },
5"Student":{ "name":"Gussy", "country":"USA", "ContactNo":9856452100}
6}';  
7
8// Database connection
9$conn = new mysqli('localhost', 'username', 'password', 'databasename');
10
11// Insert data Query
12$sql = "INSERT INTO student_table ( name, jsondata )
13VALUES ('Multidata', '$josndata')";
14
15if ($conn->query($sql) === TRUE) {
16  echo "Insert your Multiple JSON record successfully";
17} 
18?>