将 PHP 代码存储在 MySQL 上并让它运行 [英] Store PHP code on MySQL and get it to run
问题描述
我有一个拥有自定义 CMS 的客户.HTML 联系表单页面存储在 MySQL 表中.我需要修改表单,我需要将 PHP 和 MySQL 查询添加到表单中,以便使用存储在同一数据库上另一个表中的值填充 Combobox.
I have a client that has a custom CMS. The HTML contact form page is stored on MySQL table. I need to modify the form and I need to add PHP and MySQL query to the form for populate Combobox with values stored on another table on same DB.
当我尝试在该表单上(在 MySQL 表上)插入 PHP 代码时,php 代码不会呈现.例如,如果我添加
When I try to insert PHP code on that form (on the MySQL table) the php code does not render. For instance if I add
<?php echo "string"; ?>
在浏览器的 DB 字段中存储的 HTML 代码中间呈现:
in the middle of HTML code stored on DB field on browser is rendered:
<!--?php echo "string"; ?-->
所以,没有显示.
我在数据库上需要修改的内容如下:
What I have on DB and need to modify is the following:
我在 DB 上存储了一个表单,其中一个输入是文本框.这需要更改为下拉菜单,其中的选项是从数据库表字段之一填充的.因此需要在 HTML 表单中间有 php 和 mysql 查询...
I have a form stored on DB and one of the inputs is a text-box. That need to be changed to a dropdown menu with the options being populated from one of the DB tables fields. Hence the need to have php and mysql query in the middle of HTML form...
推荐答案
$str = '<?php echo "string"; ?>'; // Your DB content
eval("?> $str <?php ");
这篇关于将 PHP 代码存储在 MySQL 上并让它运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!