There are two projects in the manual on the cakephp.org site:
* Setting up a user login system
* Setting up a blog
There are other examples of "first day CakePHP" at IBM.com; do a web
search for IBM CakePHP for those.
Given your questions, the first tutorial might help the most; for
displaying user data I'd suggest the following after you do that
tutorial.
In the users table add the field Age to the database. (Also consider a
"birthday" field.)
Add a function to the Users_controller class:
function index(){ $this->data = $this->Users->findAll(); }
then create a view in /views/users/index.thtml
<table>
<tr>
<th>Name</th>
<th>Username</th>
<th>Birthday</th>
<th>Age</th>
</tr>
<? foreach ($this->data as $row){
$age = get_age($row);
?>
<tr>
<td><?= $html->link( $row['User']['name'], '/users/view/' .
$row['User']['id']) ?></td>
<td><?= $row['User']['username'] ?></td>
<td><?= $row['User']['birthday'] ?></td>
<td><?= $age ?></td>
</tr>
<? } // end foreach
?>
</table>
<?
function get_age($user)
{
return $user['User']['Age'];
}
Note: this is "off the cuff" code -- its not been tested. For a
production site, age should really be a computation of the difference
in years between the users' birthday and the current date. This would
be a more complex function get_age(); reference the date sections in
the PHP manual for details. Make sure when working on that to pay
attention to the format of the birthday field as echoed in the view.
Some date functions like (I think) strtodate($date) translate strings
to integers (representing seconds) -- others take integers (seconds)
and translate them into date displays. Date is always a delicate
problem and requires research and attention.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---