Hello to all, welcome to therichpost.com. In this post, I will tell you How to change MySQL data in JSON format? When we want to send data one page to other page then we can use json formatted data. We will save Mysql data in json format.
We can this json formatted data jquery ajax request get or post.
Please check the working example of change MySQL data in JSON format:
$con=mysqli_connect($servername,$username,$password,$databasename);
if (mysqli_connect_errno())
{
echo “Connection Error” . mysqli_connect_error();
}
$query = “SELECT * FROM TableName”;
$result = mysqli_query($con,$query);
$querydata = array();
while($data = mysqli_fetch_array($result)) {
$querydata[] = $data;
}
echo json_encode($querydata);
mysqli_close($con);
There are so many queries in Mysql and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com
You Might Also Like
How to set Laravel Default Auth with custom User type Field?
Hello to all, welcome to therichpost.com. First of all, I just want to wish you all very Happy Diwali.In this...
Node Js – Fetch Mysql Data With Nodejs
Hello to all, welcome to therichpost.com. In this post, I will do, Node Js - Fetch Mysql Data With Nodejs.Working with...
Database Seeding in Laravel 5.7 With Faker Package
Hello to all, welcome to therichpost.com. In this post, I will do, Database Seeding in Laravel 5.7 With Faker Package.In this...