gpt4 book ai didi

php - 如何使用它的 id 从数据库中调用 HTML 代码

转载 作者:行者123 更新时间:2023-11-30 22:21:50 25 4
gpt4 key购买 nike

我有一个名为blocks 的表 enter image description here

我在 Controller 中使用这个查询并在 View 中编写代码来显示这个模板..

Controller

$blocks = $this->model->getData("SELECT * FROM `blocks`");

查看

@foreach($blocks as $block)
<?php $str = $block->template;
echo $str. "\n";
?>
@endforeach

实际上它从表中检索所有内容并在 View 中显示所有模板

但是,如果我只需要调用 briefcase identifier 的模板。我只想调用标识符名称。

这可能使用查询。但我不需要它。

由于我的表有超过 20 个这样的数据,所以我认为使用查询不是一件好事,

如果 identifier_name 被调用,是否有任何其他方式显示该 template..

有人帮助我..谢谢,

最佳答案

你应该选择你需要的id

$blocks = $this->model->getData("SELECT * FROM `blocks` where identifier = 'briefcase'");

关于php - 如何使用它的 id 从数据库中调用 HTML 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36468329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com