Dear cpeele,
I see your question is not clearly , what do you want when you use this
query $projects = $this->Project->User->findByUsername($username);, and
please post your database on forum

2009/3/19 cpeele <[email protected]>

>
>
> Hey guys, I am getting an Undefined index error. I am rather new to
> cakePHP so it is probably something easy I am missing.
> I will post the code with descriptions.
>
> I have an element called "project_updates":
> <table>
>        <?php foreach($projects as $project): ?>
>        <?php $dateTime = date_create($project['Project']['created']); ?>
>        <tr>
>                <td>
>            <!-- ************   This link passes the "username" into
> the ProjectController's view method taking the username as an argument
> *******************-->
>                        <?php echo $html->link($project['Project']['name'],
> "/projects/
> view/".$project['User']['username']); ?><br />
>
>                        <span style="font-size:12px"><?php echo
> $project['User']
> ['username'] . " - " . date_format($dateTime, 'd/M/y'); ?></span>
>                </td>
>        </tr>
>        <tr>
>                <td style="padding-top: 10px;">
>                        <?php echo $project['Project']['description']; ?>
>                </td>
>        </tr>
>        <tr>
>                <td><br /></td>
>        </tr>
>        <?php endforeach ?>
> </table>
>
> here is the ProjectsController action code:
>
>        function view($username)
>        {
>                $projects = $this->Project->User->findByUsername($username);
>                $this->set('projects', $projects);
>        }
>
> Project has a foreign key reference to User. I want to grab all the
> projects by a particular username that is being passed in by the above
> element.
>
> Here is the view.ctp code
>
>        <?php foreach($projects as $project): ?>
>                <?php echo $project['Project']['name']; ?>
>        <?php endforeach ?>
>
> When it tries to echo the project name it throws the undefined index
> error.
>
> Any help would be greatly appreciated!
>
> Thanks,
>
> Chris
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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