?
Solved

How can I populate a drop down (<select>) using cakePHP via MySql database

Posted on 2008-10-16
4
Medium Priority
?
9,281 Views
Last Modified: 2013-12-13
I am trying to find out how to populate a HTML select object using CakePHP with a MySQL database? Say I want to fill in categories from my categories database, to keep it dynamic? Any ideas?

Thanks,

Ryan
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
wildzero earned 2000 total points
ID: 22749439
Hi there,

In your controller's action you need to select all the items you want, and then send them to the view
$options = $this->Categories->find('all');
$this->set('options', $options);

Then in the view you can use the form helper like
<?php $form->input('categories' => array('options' => $options)); ?>

Thats pretty rough, but it should give you a good idea :-)
0
 
LVL 10

Expert Comment

by:wildzero
ID: 22749447
Take a look at this
http://groups.google.com/group/cake-php/browse_thread/thread/475236491480fb3d/d12c1baf5cf1f751
pretty much the same question you have, and Wayne Madison writes a pretty good reply
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 22778966
Thank you! I want to keep playing with Cake to build some apps! I feel like when you understand it you can start to develp apps on the fly or well i should say much faster than traditional PHP.

Ryan
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question