如何在 CakePHP 中使用数据库值填充下拉列表 [英] How to populate drop-down list with database values in CakePHP
本文介绍了如何在 CakePHP 中使用数据库值填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 CakePHP 很陌生.您能否向我解释使用数据库中的值填充选择下拉列表所需的步骤.还请给我推荐一些参考文献的链接.
I am very new to CakePHP. Could you please explain me the steps needed to populate a select drop-down with values from the database. Please also suggest me some links to the reference.
推荐答案
您在数据库中进行查找,然后通过控制器中的 $this->set(yourvariable)
设置变量.
You make a find in the db and then set the variable via $this->set(yourvariable)
in the controller.
在视图中,您在 select 标签中使用yourvariable"
In the view you use the "yourvariable" in the select tag
这篇关于如何在 CakePHP 中使用数据库值填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文