WE create the following table, IT seems its working for few in our
team in Wamp but not in xampp.  In Xampp the 
http://localhost/little_job/WebContent/ljs/admins
link is not working, find listed below the controller and table



CREATE TABLE IF NOT EXISTS `admins` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(25) NOT NULL,
 `password` varchar(150) NOT NULL,
 `created` datetime NOT NULL,
 PRIMARY KEY (`id`)
)
Admin Sql
Admin Controller :



class AdminsController extends AppController {

       var $name = 'Admins';

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

       var $uses =  array('Order', 'User', 'Bookmark', 'Job', 'Admin',
'Payment', 'Affiliate', 'Message');


       Config::write('debug',2);

               function index()
               {
                       $this->Admin->recursive = 0;
                       $this->set('users', $this->paginate());
               }


       function view($id = null) {
               if (!$id) {
                       $this->Session->setFlash(__('Invalid Admin',
true));
                       $this->redirect(array('action' => 'index'));
               }
               $this->set('admin', $this->Admin->read(null, $id));
       }

       function add() {
               if (!empty($this->data)) {
                       $this->Admin->create();
                       if ($this->Admin->save($this->data)) {
                               $this->Session->setFlash(__('The Admin
has been saved', true));
                               $this->redirect(array('action' =>
'index'));
                       } else {
                               $this->Session->setFlash(__('The Admin
could not be saved. Please, try again.', true));
                       }
               }
       }

       function edit($id = null) {
               if (!$id && empty($this->data)) {
                       $this->Session->setFlash(__('Invalid Admin',
true));
                       $this->redirect(array('action' => 'index'));
               }
               if (!empty($this->data)) {
                       if ($this->Admin->save($this->data)) {
                               $this->Session->setFlash(__('The Admin
has been saved', true));
                               $this->redirect(array('action' =>
'index'));
                       } else {
                               $this->Session->setFlash(__('The Admin
could not be saved. Please, try again.', true));
                       }
               }
               if (empty($this->data)) {
                       $this->data = $this->Admin->read(null, $id);
               }
       }

       function delete($id = null) {
               if (!$id) {
                       $this->Session->setFlash(__('Invalid id for
Admin', true));
                       $this->redirect(array('action' => 'index'));
               }
               if ($this->Admin->del($id)) {
                       $this->Session->setFlash(__('Admin deleted',
true));
                       $this->redirect(array('action' => 'index'));
               }
               $this->Session->setFlash(__('The Admin could not be
deleted. Please, try again.', true));
               $this->redirect(array('action' => 'index'));
       }

}
Admin View :



<div class="admins index">
<h2><?php __('Admins');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out
of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
       <th><?php echo $paginator->sort('id');?></th>
       <th><?php echo $paginator->sort('username');?></th>
       <th><?php echo $paginator->sort('password');?></th>
       <th><?php echo $paginator->sort('created');?></th>
       <th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($admins as $admin):
       $class = null;
       if ($i++ % 2 == 0) {
               $class = ' class="altrow"';
       }
?>
       <tr<?php echo $class;?>>
               <td>
                       <?php echo $admin['Admin']['id']; ?>
               </td>
               <td>
                       <?php echo $admin['Admin']['username']; ?>
               </td>
               <td>
                       <?php echo $admin['Admin']['password']; ?>
               </td>
               <td>
                       <?php echo $admin['Admin']['created']; ?>
               </td>
               <td class="actions">
                       <?php echo $html->link(__('View', true),
array('action' => 'view', $admin['Admin']['id'])); ?>
                       <?php echo $html->link(__('Edit', true),
array('action' => 'edit', $admin['Admin']['id'])); ?>
                       <?php echo $html->link(__('Delete', true),
array('action' => 'delete', $admin['Admin']['id']), null,
sprintf(__('Are you sure you want to delete # %s?', true),
$admin['Admin']['id'])); ?>
               </td>
       </tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
       <?php echo $paginator->prev('<< '.__('previous', true),
array(), null, array('class'=>'disabled'));?>
|         <?php echo $paginator->numbers();?>
       <?php echo $paginator->next(__('next', true).' >>', array(),
null, array('class' => 'disabled'));?>
</div>
<div class="actions">
       <ul>
               <li><?php echo $html->link(__('New Admin', true),
array('action' => 'add')); ?></li>
       </ul>
</div>
Admin Model :

<?php
class Admin extends AppModel {

       var $name = 'Admin';
       var $validate = array(
               'username' => array('notempty'),
               'password' => array('notempty')
       );

}
?>
 Sent at 12:10 PM on Sunday


Pop-in

THANKS FOR HELP

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