I'm going to be writing a class to teach people how to do this, but I can give you the basics.
So there are two tricks with this.
1. Write a query that takes the id of the task and finds all the existing info on that task...
So when you're loading the page you want
(I'm assuming the task_id is a $_Get variable in the URL)
Code:
$task_id = Input::get('id');
Code:
$tasksQ = $db->query("SELECT * FROM tasks WHERE task_id = ?",array($task_id));
Code:
$tasks = $tasksQ->results();
2. Create your form like you did, but on each checkbox, have the db check to see if that box is assigned. (I can't see your code to know how you did this. Essentially what you want to do is to pass the id (NOT task_id) into the form and whether or not you want the box to be checked.
How do you know if you want the box checked? You need to write a function that does the db query and if it should be checked, it returns checked. The input should look like...
Code:
<input type="checkbox" id="employee" name="employee[]" value='<?=$v1->id?>'
Code:
<?php checkTask($v1->id,$id); ?> ><?=$v1->fname." "; ?>
checkTask is what I called your function that queries the db and looks for what should be checked. I'll show you an example of my checkDuty function that queries a different db table....
Code:
function checkDuty($employee,$workorder){
Code:
$db = DB::getInstance();
Code:
$q=$db->query("SELECT id FROM employee_jobs WHERE employee = ? AND workorder = ?",array($employee,$workorder));
Code:
echo "checked='checked'";
Then, once the form is all done, you need to check the boxes that were checked in the form and uncheck the ones that weren't. My feeling is that it is easiest to just write every single box over again as opposed to only the ones that changed.