Hi,
I am new on this community..can any body help me for paging.
this is my file:
<h1 style="padding-left:100px;">Admin Panel</h1>
<p style="color:#FFFFFF"><?php echo $html->link('Add User', 'http://
192.168.0.60/vishal/cake_1.2.0.6311-beta/app/users/add'); ?></p>
<table width="90%" cellpadding="5" cellspacing="1" class="ITableT1"
align="center" border="0">
<tr class=thead>
<td align="center" width="15%" >Name
</td>
<td align="center" width="30%">Address
</td>
<td align="center" width="15%">Phone
</td>
<td align="center" width="20%">Email
</td>
<td align="center" width="20%">Action
</td>
</tr>
<!-- Here's where we loop through our $users array, printing out user
info -->
<?php foreach ($data as $user): ?>
<tr style="background-color:#27313B">
<td align="center" class="td2"><?php echo
$user['User']['name']; ?></
td>
<td align="center" class="td2"><?php echo
$user['User']['address']; ?
></td>
<td align="center" class="td2"><?php echo
$user['User']['phone']; ?
></td>
<td align="center" class="td2"><?php echo
$user['User']['email']; ?
></td>
<td align="center"><a href="http://192.168.0.60/vishal/
cake_1.2.0.6311-beta/app/users/delete/<?php echo $user['User']['id']; ?
>">Delete</a>
<?php // echo $html->link('Delete',
"'http://192.168.0.60/vishal/
cake_1.2.0.6311-beta/users/{$user['User']['id']}", null, 'Are you
sure?' )?>
<?php echo $html->link('Edit User', "http://192.168.0.60/vishal/
cake_1.2.0.6311-beta/app/users/edit/{$user['User']['id']}" )?>
</td>
</tr>
<?php endforeach; ?>
</table>
this is my controller file:
<?php
class UsersController extends AppController {
var $name = 'Users';
var $layout='user';
var $components = array('Upload');
//*****************************
var $paginate = array(
'limit' => 4,
'order' => array(
'User.name' => 'asc'
)
);
//****************************
function index() {
//$this->set('users', $this->User->find('all'));
$data = $this->paginate('User');
$this->set(compact('data'));
}
function view($id) {
$this->User->id = $id;
$this->set('user', $this->User->read());
}
function delete($id) {
$this->User->del($id);
$this->flash('The user with id: '.$id.' has been deleted.', 'http://
192.168.0.60/vishal/cake_1.2.0.6311-beta/app/users/index');
}
function add() {
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
echo $this->data['User']['image'];
$destination =
realpath('../../app/webroot/img/uploads/') . '/';
// grab the file
$file = $this->data['User']['image'];
// upload the image using the upload component
$result = $this->Upload->upload($file, $destination, null,
array('type' => 'resizecrop', 'size' => array('400', '300'), 'output'
=> 'jpg'));
if (!$result){
$this->data['User']['image'] = $this->Upload->result;
} else {
// display error
$errors = $this->Upload->errors;
// piece together errors
if(is_array($errors)){ $errors = implode("<br
/>",$errors); }
$this->Session->setFlash($errors);
//$this->redirect('/images/upload');
exit();
}
if ($this->User->save($this->data)) {
$this->Session->setFlash('Image has been added.');
//$this->redirect('/images/index');
} else {
$this->Session->setFlash('Please correct errors
below.');
unlink($destination.$this->Upload->result);
}
$this->flash('Your detail has been
saved.','http://192.168.0.60/
vishal/cake_1.2.0.6311-beta/app/users/index');
}
}
}
function edit($id = null) {
$this->User->id = $id;
if (empty($this->data)) {
$this->data = $this->User->read();
} else {
if ($this->User->save($this->data['User'])) {
$this->flash('Your detail has been updated.',
array('action' =>
'index'));
}
}
}
}
?>
Please tell me the correct code for puuting paginf on my index page.
thanks in advance everybody..if you have few minutes for me..
vishu
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---