You want to convert the result array of a database query to JSON format in PHP. The following code retrieves a row from the database:
$row = mysql_fetch_array($result);
To convert the $row array to JSON format for use with jQuery plugins, you can utilize the json_encode function:
echo json_encode($row);
Note that json_encode is only available in PHP version 5.2.0 and above. If you are using an earlier PHP version, you may need to use a third-party library or write your own JSON encoding function.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3