I want to update data to multiple ids, I take all ids
controller
public function getIds(){
for($i=0;$i<count($_POST['std_id']);$i++){
echo $_POST['std_id'][$i];
$student_id[]=$_POST['std_id'][$i];
}
I don't know how to update this?
How to write the modal function?
You don't have to create separate array for that. You can pass $_POST['std_id]
which is having array of id
s.
controller
$this->modelname->mymethod($_POST['std_id'],$updateData);
where $_POST['std_id']
is an array of ids and $updateData
for updating fields
model
function mymethod($idArr,$data){
$this->db->where_in("fieldname", $idArr);
$this->db->update("tablename",$data);
}
you can use where_in
for mysql IN
to check multiple ids.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With