English 中文(简体)
为什么要进行负荷工作?
原标题:loadmodel dont work why?

in the sections_controller i use loadmodel to print username in sections/index file but i get error :
Notice (8): Undefined variable: user [APPviewssectionsindex.ctp, line 3]

public function index ()
        {

       $this->loadModel( User );
      $user = $this->User->find( all );
       $this->Section->find( threaded , array( order  => array( Section.created ASC )));
       $this->set( data , user );
          }

段 次 页 次

<div><?php echo $user[ User ][ username ]; ?></div>
最佳回答

你们不要适当分配变量,而是试图这样做:

$this->set( user , $user);

<代码> 用户系指您的发现结果,并作为<编码>用户<>/代码>,因为这符合你在你看来再次要求的内容。 或者使用<代码>compact代号表示:

$this->set(compact( user ));

你们现在做的是制定一种称为<条码>的数据的变数,其载值为<条码>用户<>/条码>,因此,你认为:

echo $data;

它将把<条码>用户作为你认为的示意图。

http://www.ohchr.org。

由于发现(所有)将回到一个阵列,确保你也能从你们的角度来看待结果。

foreach($user as $u) {
    echo $u[ User ][ username ];
}

或者,如果你想要取得具体成果,就把它称为阵列钥匙,对第一使用者来说,这将:

echo $user[0][ User ][ username ];
问题回答

你们有打字,尝试:

$this->set( data ,$user);

之后,您认为:

<div><?php echo $data[ User ][ username ]; ?></div>

希望这一帮助!





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签