[eluser]Phil Sturgeon[/eluser]
That would be to update payments for multiple items. We only need a single check box to show this.
Add a field called 'paid_date' to the database type of Integer and 11 digits long.
Get the data from the user and output to page.
Code:
<?php
class Controller {
function edit($id) {
$data['user'] = $this->user_model->get($id);
if($this->input->post('has_paid')) {
// Update the user with the date they paid
$this->user_model->paid($id);
}
$this->load->view('something', $data);
}
}?>
In your form view, add:
Code:
<?=form_open('controller');?>
Has Paid? <?=form_checkbox('has_paid', TRUE, !empty($user->has_paid));?>
The model would be
Code:
<?php
class user_model {
function get($id) {
$query = $this->db->getwhere('users', array('id' => $id));
return $query->row();
}
function paid($id) {
$this->load->helper('date');
return $this->db->update('users', array('paid_date' => now()));
}
}
?>
That is a very rough outline, a few steps up from pseudo code. Hope it helps.