[英]getting values from mysql database into javascript in wordpress
I am making a wordpress plugin. 我正在制作一个wordpress插件。 I am having trouble finding documentation on how to get values from a mysql database into a javascript in wordpress.
我在查找有关如何将mysql数据库中的值获取到wordpress中的javascript中的文档时遇到麻烦。 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.
当人们不使用wordpress软件时,我已经看到了一些示例,但是我不确定是否有更好的方法或需要更好的安全性,因为它是wordpress。
could anyone post a link to a helpful article or show a example? 任何人都可以发布有用文章的链接或显示示例吗?
You can use JSON to construct data representation in Javascript. 您可以使用JSON构造Javascript中的数据表示形式。
For that, I suggest you use a intermediary PHP page to control ACLs (ie restrict unauthorized access) and construct the JSON data/array. 为此,我建议您使用一个中间PHP页面来控制ACL(即,限制未经授权的访问)并构造JSON数据/数组。
A simple way to take MySQL data to JSON in PHP: JSON encode MySQL results 在PHP中将MySQL数据转换为JSON的简单方法: JSON编码MySQL结果
More PHP JSON documentation here: http://php.net/manual/en/book.json.php 此处提供了更多PHP JSON文档: http : //php.net/manual/zh/book.json.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.