Categories

Thursday, November 21, 2024
#919814419350 therichposts@gmail.com
JsonMysqlPhp

How to change MySQL data in JSON format?

change MySQL data in JSON format

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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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