The page_id in pages table matches with campaign_page_id in the campaign table.
TABLES: campaign: campaign_id INT, campaign_page_id INT pages: page_id INT, page_url VARCHAR MODELS: campaign.php class Campaign extends AppModel { var $name = 'Campaign'; var $useTable = 'campaign'; var $primaryKey = 'campaign_id'; var $belongsTo = array('Page' => array('className' => 'Page', 'conditions' => '', 'order' => '', 'foreignKey' => 'page_id' ) ); } page.php class Page extends AppModel { var $name = 'Page'; # equals name of the field "vendor" in table "vendors". # by convention first column in all tables, must be "id". var $useTable = 'pages'; var $primaryKey = 'page_id'; var $hasMany = array('Campaign' => array('className' => 'Campaign', 'conditions' => '', 'order' => '', 'foreignKey' => 'campaign_page_id', ) ); } pages_controller.php class PagesController extends AppController { var $name = 'Pages'; function display() { $this->set('data', $this->Page->findAll()); } } here is the view: foreach ($data as $output): ?> <tr> <td> <?php echo $output['Page']['page_id']?> </td> <td> <?php echo $output['Page']['page_url']?> </td> <td> <?php echo $output['Campaign']['campaign_page_id']?> </td> </tr> <?php endforeach; ?> page_id and page_url show up fine, but campaign_page_id does not. I get this error: Undefined index: campaign_page_id I just started in CakePHP, so I don't know if my error is in the models, controller, or view. Please help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---