cakephp:从“;汽车类型”;表中的“;users_controller.php”;文件

cakephp:从“;汽车类型”;表中的“;users_controller.php”;文件,php,cakephp-1.3,Php,Cakephp 1.3,我有表“汽车类型”,一个控制器用户控制器和动作url localhost/carsdirectory/users/dashboard 在users\u controller.php文件中,我使用了该函数 public function dashboard(){ $this->set('users', $this->Car_type->find('all')); } 我想从汽车类型中检索数据并显示 localhost/carsdirectory/users/da

我有表“汽车类型”,一个控制器用户控制器和动作url

  localhost/carsdirectory/users/dashboard
在users\u controller.php文件中,我使用了该函数

 public function dashboard(){

$this->set('users', $this->Car_type->find('all'));

}
我想从汽车类型中检索数据并显示

  localhost/carsdirectory/users/dashboard   in select box
我发现了那些错误

Undefined property: UsersController::$Car_type
我知道,我错了,但无法解决那个问题


请帮我提前谢谢,vikas tyagi

看来用户和车型之间没有关系,你可以做:


$this->loadModel('CarType'); // your Model name => CarType
//then
$this->set('users', $this->CarType->find('all'));
要在selectbox中填充它,类似这样的操作应该可以:


<select>
<?php foreach($users as $key => $val) { ?>
<option value="<?php echo $val['CarType']['id']; ?>">
      <?php echo $val['CarType']['car_type']; ?>
</option>
<?php } ?>
</select>


希望对我有帮助

它对我有效,现在没有错误,你能告诉我一件事吗?如何从Car_types表中获取数据到选择框(我在Car_types表中有两个字段1.id,2.Car_type,我想在选择框中获取Car_type字段的数据)谢谢againi已将CarType更改为Car_type bcoz型号名称为Car_type,它对我有效,多谢各位