Updating with a Checkbox - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Updating with a Checkbox (/showthread.php?tid=13991) |
Updating with a Checkbox - El Forum - 12-14-2008 [eluser]EvanCalkins[/eluser] Hello, 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? Updating with a Checkbox - El Forum - 12-15-2008 [eluser]Kotzilla[/eluser] 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) { for($i=0;$i<count($_POST['item']);$i++) { /* SQL statement like ' update table set item='$_POST['item'][$i]' where id='$id'; ' } } =) Updating with a Checkbox - El Forum - 12-15-2008 [eluser]EvanCalkins[/eluser] Great! I'll give this a go. Updating with a Checkbox - El Forum - 12-15-2008 [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 In your form view, add: Code: <?=form_open('controller');?> The model would be Code: <?php That is a very rough outline, a few steps up from pseudo code. Hope it helps. Updating with a Checkbox - El Forum - 12-15-2008 [eluser]Kotzilla[/eluser] Thank's for sharing pyromaniac That's great idea |