[英]PHP not displaying MathJax from MySQL
Hello I'm stuck rendering MathJax from MySQL database.您好,我无法从 MySQL 数据库中渲染 MathJax。 Since I couldn't find the right answer I would like to ask about rendering MathJax from MySQL database with PHP.由于找不到正确的答案,我想问一下如何使用 PHP 从 MySQL 数据库渲染 MathJax。
The MathJax code renders when I write it through text editor directly to the page.当我通过文本编辑器将 MathJax 代码直接写入页面时,它会呈现。 ( https://i.stack.imgur.com/wkkvA.png ) But when I save it to the database and try to echo
saved data it doesn't apply MathJax style. ( https://i.stack.imgur.com/wkkvA.png ) 但是当我将它保存到数据库并尝试echo
显保存的数据时,它不应用 MathJax 样式。 ( https://i.stack.imgur.com/EQsql.png ). ( https://i.stack.imgur.com/EQsql.png )。
I'm storing the data as TEXT in MySQL. ( https://i.stack.imgur.com/TPrIc.png ) I'm adding MathJax to website through我将数据作为 TEXT 存储在 MySQL 中。 ( https://i.stack.imgur.com/TPrIc.png ) 我正在通过以下方式将 MathJax 添加到网站
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>`
I've tried to read the MathJax docummentation but i wasn't able to find solution.我试图阅读 MathJax 文档,但找不到解决方案。 I've also tried googling i couldn't find answer that would help me.我也试过谷歌搜索我找不到对我有帮助的答案。
I tryed this and it works:我试过这个并且有效:
<head>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body>
<div id="has-math">
<div id="preview">\(\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1){6}\)</div>
<br> Original: \sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}
</div>
<script>
MathJax.typeset();
</script>
</body>
So put your content in the 'preview' div: <div id="preview">\(\)</div>
因此,将您的内容放在“预览”div 中: <div id="preview">\(\)</div>
like <div id="preview">\(1+1\)</div>
像<div id="preview">\(1+1\)</div>
The rest is on you:-) rest 在你身上:-)
Did research here on the fly and is a very complex tool.在这里进行了即时研究,是一个非常复杂的工具。
Notice: This just shows what you have saved and loaded from db and you can not edit it.注意:这只是显示你从数据库中保存和加载的内容,你不能编辑它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.