try to debug something like:

controller:

$tasks = $this->Task->find('all');
print_r($tasks);
$this->set('tasks', $tasks);

view:
<?php prin_r($tasks): ?>

Andras


On Feb 6, 2009, at 11:39 PM, abhishek wrote:

>
> I am writing a simple TASK application: with 1 model, 1 controller,and
> 2 views.
> In the application, you can add a task and it shows a list of all the
> tasks.
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated fine, which means it is working I don't know
> why the data is not showing in the index view.
>
> Thanks a lot.
>
> My database:
> CREATE TABLE tasks(
>       id int(10) unsigned NOT NULL auto_increment,
>       title varchar(255) NOT NULL,
>       done tinyint(1) default NULL,
>       created datetime default NULL,
>       modified datetime default NULL,
>       PRIMARY KEY (id)
> );
>
> MODEL
> <?php
> class Task extends AppModel{
>       var $name = 'Task';
> }
> ?>
>
>
> THE CONTROLLER
> <?php
> class TasksController extends AppController{
>
>       var $name = 'Tasks';
>       var $helpers = array('Html', 'Form');
>       function index(){
>               $this->set('tasks', $this->Task->find('all'));
>
>       }
>
>    function add(){
>        if (!empty($this->data)){
>            $this->Task->create();
>            if ($this->Task->save($this->data)){
>                $this->Session->setFlash('Task has been saved');
>                $this->redirect(array('action'=>'index'),null, true);
>
>            }else{
>                $this->Session->setFlash('Task not saved. Try
> again.');
>            }
>        }
>
>    }
> }
> ?>
>
> VIEW INDEX
>
> <h2>TASKS</h2>
> <?php if(empty($tasks)): ?>
>       There are no tasks in this list
> <?php else: ?>
>
>       <table>
>               <tr>
>                       <th>Title</th>
>                       <th>Status</th>
>                       <th>Created</th>
>                       <th>Modified</th>
>                       <th>Actions</th>
>               </tr>
>
>               <?php foreach($tasks as $task): ?>
>                       <tr>
>                               <td>
>                                       <?php $task['Task']['title'] ?>
>                               </td>
>
>                               <td>
>                                       <?php if($task['Task']['done']) echo 
> "Done";
>                                               else echo "Pending";
>                                       ?>
>                               </td>
>                               <td>
>                                       <?php $task['Task']['created'] ?>
>                               </td>
>                               <td>
>                                       <?php $task['Task']['modified'] ?>
>                               </td>
>                               <td>
>
>                               </td>
>                       </tr>
>               <?php endforeach; ?>
>       </table>
>
>
> <?php endif; ?>
> <?php echo $html->link('Add Task', array('action'=>'add')); ?>
>
>
> VIEW ADD:
> <?php echo $form->create('Task'); ?>
>
> <fieldset>
>
>    <legend>
>        Add New Task
>    </legend>
>    <?php
>        echo $form->input('title');
>        echo $form->input('done');
>    ?>
> </fieldset>
> <?php echo $form->end('Add Task');?>
>
> <?php echo $html->link('List All Task', array('action'=>'index')); ?>
>
>
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated. But it doesn't show in the view.
>
> >

Andras Kende
http://kende.com




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

Reply via email to