Skip to content

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";
} 
?>
See also  Python code snippet - How to connect an ml model to a web application?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.