• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating with a Checkbox


I am fairly new to Code Igniter ( and php ) and have a question on a very small application I'm developing for my church.

I am building a small system that allows youth to sign up for camp online, and record those registrants into a database. I am then creating a simple back-end for the church admin to view all the registrants and update their record if they have paid.

Currently, I have all the records being pulled from the database and spit out into a simple table. I need the ability for a church admin to go into this a check a checkbox if the registrant has paid, and on submit, the database would update the 'paid' field.

Would someone care to give me an idea of what this action would look like?

i used array checkbox like
<input type="checkbox" name="item[]" value="<?php echo $itemvalue; ?>" />

when you submit data $_POST['item'] will be in Array so all i have to do is

if(is_array($_POST['item']) && count($_POST['item']) >= 1)
/* SQL statement like ' update table set item='$_POST['item'][$i]' where id='$id'; '


Great! I'll give this a go.

[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.

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->load->view('something', $data);



In your form view, add:

Has Paid? &lt;?=form_checkbox('has_paid', TRUE, !empty($user->has_paid));?&gt;

The model would be


class user_model {

  function get($id) {
    $query = $this->db->getwhere('users', array('id' => $id));
    return $query->row();

  function paid($id) {
    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.

Thank's for sharing pyromaniac
That's great idea Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.