简体   繁体   English

在 Wordpress 中从表单调用变量以呈现图表

[英]Calling Variable from Form to Render Chart in Wordpress

I am trying to use a Wordpress chart generation plugin, but call a variable that the user sets on the page.我正在尝试使用 Wordpress 图表生成插件,但调用用户在页面上设置的变量。 I've got the chart code in and it works at a rudimentary level and I was able to add a form to the page in which a user could enter a number and submit it, but the PHP code for calling the variable from the form breaks the chart code, I believe because the chart code looks for a ] character to determine where to conclude the chart script.我已经有了图表代码,它在基本级别上工作,我能够向页面添加一个表单,用户可以在其中输入一个数字并提交它,但是用于从表单调用变量的 PHP 代码中断了图表代码,我相信是因为图表代码会寻找一个 ] 字符来确定在何处结束图表脚本。

As follows:如下:

Chart Code: [easychart type="pie" height="100" width="100" title="US Federal Expenditures, 2011 Fiscal Year" groupnames="Unfunded, Funded" valuenames="Unfunded, Funded" group1values="80" group2values="<?php ?get_percent = $_POST['percent']; echo$percent; ?>"]图表代码: [easychart type="pie" height="100" width="100" title="US Federal Expenditures, 2011 Fiscal Year" groupnames="Unfunded, Funded" valuenames="Unfunded, Funded" group1values="80" group2values="<?php ?get_percent = $_POST['percent']; echo$percent; ?>"]

If I replace <?php ?get_percent = $_POST['percent']; echo$percent; ?>如果我替换<?php ?get_percent = $_POST['percent']; echo$percent; ?> <?php ?get_percent = $_POST['percent']; echo$percent; ?> <?php ?get_percent = $_POST['percent']; echo$percent; ?> with 20, the chart works fine. <?php ?get_percent = $_POST['percent']; echo$percent; ?> 20,图表工作正常。 Again, I believe it is because of the ] character after the percent POST command.同样,我相信这是因为百分比 POST 命令后面的 ] 字符。

I'm probably barking up the wrong tree altogether.我可能完全找错了树。 Basically I just want the user to be able to manipulate the chart.基本上我只是希望用户能够操作图表。

Help?帮助?

Thanks谢谢

Try changing: group2values="<?php ?get_percent = $_POST['percent']; echo$percent; ?>" To: group2values="<?php echo $_POST['percent']; ?>"尝试更改: group2values="<?php ?get_percent = $_POST['percent']; echo$percent; ?>" To: group2values="<?php echo $_POST['percent']; ?>"

Basically the first part ( ?get_percent = $_POST['percent']; ) was unnecessary, and if you did need it, it should read $get_percent = $_POST['percent'];基本上第一部分( ?get_percent = $_POST['percent']; )是不必要的,如果你确实需要它,它应该读$get_percent = $_POST['percent']; . . You put a ?你放一个? instead of $ .而不是$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM