![]() |
Codeigniter 3: update Sql table column via GET - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Codeigniter 3: update Sql table column via GET (/showthread.php?tid=69760) |
Codeigniter 3: update Sql table column via GET - Ajax30 - 01-14-2018 I am working on a Register and Login application with CodeIgniter 3 and Bootstrap. In my "users" table I have an "active" column that can take either 0 or 1 as value. ![]() I want to be able to change the value of the "active" column corresponding to a user from 0 to 1 (activate the user) by clicking a link in my users view: Code: <a href="<?php echo base_url(); ?>users/activate/<?php echo $user->id ?>" title="Activate" class="btn btn-success btn-xs activate-btn"><span class="glyphicon glyphicon-ok"></span> Activate</a> In my Usermodel model I have: Code: public function activateUser($user_id) { In my User controller I have: Code: public function activate($user_id) { The url users/activate/1 returns "user already active" , while users/activate/2 returns "activate user", as expected. Being new to Codeigniter, I have tried numerous versions of the code above that resulted in errors. Can you please tell me what shall I change in the code to make work as desired? RE: Codeigniter 3: update Sql table column via GET - jreklund - 01-14-2018 As far I can tell, you only forgot to change the data. Replace your 'activate user' part of the code with a usermodel that actually changes the table. PHP Code: $data = array('active' => 1); RE: Codeigniter 3: update Sql table column via GET - Ajax30 - 01-14-2018 (01-14-2018, 01:34 PM)jreklund Wrote: As far I can tell, you only forgot to change the data. Replace your 'activate user' part of the code with a usermodel that actually changes the table. |