Php 将值发送到文件\u获取\u内容()
我正在制作一个网站,它使用文件内容来显示表单。表单包含三个字段,如下所示。我要做的是将我从sql查询生成的三个值插入到这个表单中 是否有一种方法可以将生成的值发送到表单的正确字段中 我是否需要在表单顶部添加一些php,以允许它接收从file\u get\u contents函数传递的值 调用函数和表单Php 将值发送到文件\u获取\u内容(),php,include,Php,Include,我正在制作一个网站,它使用文件内容来显示表单。表单包含三个字段,如下所示。我要做的是将我从sql查询生成的三个值插入到这个表单中 是否有一种方法可以将生成的值发送到表单的正确字段中 我是否需要在表单顶部添加一些php,以允许它接收从file\u get\u contents函数传递的值 调用函数和表单 //sql functions return values based on rowID $updateTilte = $this->mode
//sql functions return values based on rowID
$updateTilte = $this->model->updateTitle();
$updatePrice = $this->model->updatePrice();
$updateDescription = $this->model->updateDescription();
$rightBox = file_get_contents( "templates/update_item_form.php" );
<h2>Update Item!</h2>
<h4>Fill in the form to update an entry.</h4>
<form action="index.php" method="post">
<fieldset>
<input id='action' type='hidden' name='action' value='updateItem' />
<p>
<label for="fTitle">Title</label> <input type="text"
id="fTitle" name="fTitle" placeholder="title"
maxlength="25" required />
</p>
<p>
<label for="fPrice">Price</label> <input type="text"
id="fPrice" name="fPrice" placeholder="price"
maxlength="25" required />
</p>
<p>
<label for="fDescription">Description</label> <input type="text"
id="fDescription" name="fDescription" placeholder="description"
maxlength="500" required />
</p>
<p>
<div class="form-group">
<div class="controls">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</p>
</fieldset>
</form>
更新项目表单
//sql functions return values based on rowID
$updateTilte = $this->model->updateTitle();
$updatePrice = $this->model->updatePrice();
$updateDescription = $this->model->updateDescription();
$rightBox = file_get_contents( "templates/update_item_form.php" );
<h2>Update Item!</h2>
<h4>Fill in the form to update an entry.</h4>
<form action="index.php" method="post">
<fieldset>
<input id='action' type='hidden' name='action' value='updateItem' />
<p>
<label for="fTitle">Title</label> <input type="text"
id="fTitle" name="fTitle" placeholder="title"
maxlength="25" required />
</p>
<p>
<label for="fPrice">Price</label> <input type="text"
id="fPrice" name="fPrice" placeholder="price"
maxlength="25" required />
</p>
<p>
<label for="fDescription">Description</label> <input type="text"
id="fDescription" name="fDescription" placeholder="description"
maxlength="500" required />
</p>
<p>
<div class="form-group">
<div class="controls">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</p>
</fieldset>
</form>
更新项目!
填写表格以更新条目。
标题
价格
描述
提交
不。这不是文件内容的作用,也不是它的用途。你要找的是
它以PHP模式打开文件,执行找到的任何代码。这意味着您可以在文件中使用上面声明的变量,PHP将用它们的值替换它们
片段:
$updateTilte = $this->model->updateTitle();
include "templates/update_item_form.php";
表格:
Title您已经问了几乎相同的问题,我给了您Erik给您的相同类型的答案。^同意@Devon的评论。当你在另一个问题中已经有了答案时,不要转发。对不起,我认为这与我在上一个问题中提出的问题太不一样了question@patrick,如果您需要,我可以在您的原始问题中提供更多建议。欢迎继续讨论,我添加了另一条评论,试图帮助澄清我对控制器和视图的说明。感谢所有的帮助@Devon,我采纳了你的建议并改变了一些事情,Erik给出的答案似乎对我的其他更改有很大帮助,很抱歉重新发布!感谢您的帮助,使用$updateTitle
快速提问,当我运行代码时,我收到一个错误,说它未定义?