hi.. all

i am joining 2 tables table: table name is fixed table 1. adb_campaign
and 2. adb_users.

these two tables i ma joining.

adb_campaign table containing user_id(adb_user table) form that i want
to get the user details.

this is my campaign.php module code:
<?php
class Campaign extends AppModel
{
    var $useTable ='adb_campaign'; //the actual name of the table in
the database
    var $belongsTo = 'User';

}
?>

this is my users.php module code:

<?php
class User extends AppModel {

    var $tablePrefix = 'adb_';
    var $hasMany = 'Campaign';
}
?>

my controller are. users_controller.php code:

<?php
class UsersController extends AppController {

    var $tablePrefix = 'adb_';
   // var $scaffold;

    var $uses=array('Client','User');

    var $helpers = array('Html', 'Form');

    function mycampaigns_results() {

        $this->Client->recursive = 1;

        $clients = $this->Client->find('all');

        $this->set('clients',$clients);

    }
}
?>
my controller are. campaigns_controller.php code:

<?php
class CampaignsController extends AppController {

    var $name = 'Campaigns';
    //var $scaffold;

    var $uses = array('Client','User','Campaign');

    var $helpers = array('Html', 'Form');

    function mycampaigns_results() {

       /*$clients = $this->Client->find('all',
                                         array(
                                         'fields' =>
                                         'client_name'));
        $this->set('clients',$clients);
        $this->Campaign->recursive = 1;*/
        $campaigns = $this->Campaign->find('all');

        $this->set('campaigns',$campaigns);
    }
}
?>


and my view page is: mycampaigns_results.ctp code:

<table widtd="100%" cellpadding="3" cellspacing="1"
           border="0"class='general_content_font' style='width:100%;
align="center">
    <tr style="background: url('<?php echo $this->webroot; ?>img/
images/title2.gif') repeat-x;" height="20">
        <td bgcolor="c0c0c0">#</td><td bgcolor="c0c0c0">Job No.</td>
        <td bgcolor="c0c0c0">Campaign Name</td>
        <td bgcolor="c0c0c0">Campaign Date</td>
        <td bgcolor="c0c0c0">Status</td>

    </tr>
        <?php foreach($campaigns as $campaign): ?>
        <?php
            if ( ( $campaign['Campaign']['campaign_id'] % 2) == 0 )
                $bg_color = "#F2F2F2";
            else
                $bg_color = "#FFF";?>
        <tr style="background: <?php echo $bg_color;?> ">
        <td><?php echo $campaign['Campaign']['campaign_id'] ?></td>
        <td><?php echo $campaign['Campaign']['jobno'] ?></td>
        <td><?php echo($html->link($campaign['Campaign']
['campaign_name'],
                                   user_assign,
                                   array('class' =>'url4_font')));?>
        </td>
        <td><?php echo $campaign['Campaign']['start_date'] ?></td>
        <td><?php echo $campaign['Client']['campaign_name'] ?></td>
    </tr>
    <?php endforeach; ?>
    </table>


where i did the mistake...

please help me

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to