I am making a wordpress plugin. I am having trouble finding documentation on how to get values from a mysql database into a javascript in wordpress. I have seen examples when people are not using wordpress software, but i'm not sure if there is a better way or a need for better security because it is wordpress.
could anyone post a link to a helpful article or show a example?
You can use JSON to construct data representation in Javascript.
For that, I suggest you use a intermediary PHP page to control ACLs (ie restrict unauthorized access) and construct the JSON data/array.
A simple way to take MySQL data to JSON in PHP: JSON encode MySQL results
More PHP JSON documentation here: http://php.net/manual/en/book.json.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.