蛋糕php模型结束视图

时间:2013-07-15 18:17:16

标签: php cakephp joomla model

我是php和cake php的新手,但已经停滞了一下! 我运行创建一个票证系统,我希望它能够从单独的用户表中检索用户信息。

票证表名为MlsEventsParticipant 用户表名为User

MlsEventsParticipant有一个名为userid的字段,它是链接到用户表的

我将从2个数据库表中获取数据,并收到错误消息..

这是我得到的错误 注意(8):未定义索引:用户[APP / View / MlsEventsParticipants / index.ctp,第29行]

my model user.php

class User extends AppModel {
var $belongsTo = array(
'MlsEventsParticipant' => array(
'className' => 'User',
'foreignKey' => 'id',
'conditions' => '',
'fields' => '',
'order' => ''





My view (MlsEventsParticipant) index.ctp

<h2>Telemark Rusfri Ungdom billett oversikt</h2>


<table cellpadding="0" cellspacing="0">
    <tr>
        <th>Id</th>
        <th>userid</th>
        <th>Eventid</th>
        <th>Billett status</th>
        <th>Betalingsmåte</th>
        <th class="actions">Kjøp</th>




       </tr>
    <?php

    $i = 0;
     foreach($mlseventsparticipants as $mlseventsparticipant):  

        $class = null;
        if ($i++ % 2 == 0) {
            $class = ' class="altrow"';
        }
    ?>
     <tr<?php echo $class;?>>
        <td><?php echo $mlseventsparticipant['MlsEventsParticipant']['id']; ?></td>     
        <td><?php echo $user['user']['name']; ?></td> 
        <td><?php echo $mlseventsparticipant['MlsEventsParticipant']['eventid']; ?></td>




<?php
$paidType = '';
switch($mlseventsparticipant['MlsEventsParticipant']['paid']){
case 1:
$paidType = 'Ikke betalt';
break;
case 2:
$paidType = 'Betalt';
break;
case 3:
$paidType = 'Ikke betalt(Billett slettet)';
break;

}
?>
<td><?php echo $paidType; ?></td>>


<?php
$paidType = '';
switch($mlseventsparticipant['MlsEventsParticipant']['paid_type']){
case 1:
$paidType = 'Ukjent';
break;
case 2:
$paidType = 'Paypal';
break;
case 3:
$paidType = 'Kontant/Bankkort';
break;
case 4:
$paidType = 'Gratisbillett';
break;
}
?>
<td><?php echo $paidType; ?></td>>


              <td class="actions">     
        <?php echo $this->Form->postLink('Betalt kontant/kort',array('action' => 'Betalt', $mlseventsparticipant['MlsEventsParticipant']['id']),array('confirm' => 'Er du sikker?'));
             ?>

    </tr>
    <?php endforeach; ?>

0 个答案:

没有答案