'Php how to insert update multiple selected records under multiple categories?
have 3 static categories and tasks under these categories.If user have selected any tasks previously then these tasks are coming alreday selected as chekboxes. Now on update view 3 categories are listed with tasks that are alreday selected and user can uncheck from that tasks and can add any other task. Now i have to remove the tasks that are unchecked, insert new checked tasks and update which are alreday checked. But my code is not working properly.Currently i am trying to go into correct condition.
One point tasks values are not commar seperated into table.multiple entries are inserting for with categroy.
$Tasklist = $this->TaskModel->getAllTaskList(); // to get all tasks from tasks table
foreach($Tasklist['data'] as $val)
{
$TaskId[]= $val['task_id'];
}
$tasklistVal = $inputs_ary['selected_task_val']; // selected tasks on update form
if(array_filter($tasklistVal)!=[])
{
foreach($tasklistVal as $value)
{
if(in_array($value, $TaskId))
{
echo "update";
}else{
echo "insert delete";
}
}
}
Solution 1:[1]
Check the "insert_batch" function in codeigniter
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | J. Kim |
