sasori Posted January 30, 2010 Share Posted January 30, 2010 hi i got a problem, i dunno why my code deletes all the rows when I only tick 1 checkbox, i don't really get it LOL please help me with this here's my controller code public function delete() { $q = $this->input->post('delete'); if(isset($q)) { $this->member_model->delete($q); $this->members_area(); } else{ redirect('site/members_area'); } } here's my model code public function delete($url) { $this->db->where('bm_URL',$url); $q = $this->db->delete('bookmark'); return $q; } view code <tr><td><b>Bookmark</b></td><td><b>Delete</b></td></tr> <?php foreach($q->result() as $row):?> <?php echo "<tr>"; ?> <?php echo "<td>".anchor('site/delete'.$row->bm_URL,$row->bm_URL)."</td>"; ?> <?php echo "<td>".form_checkbox('delete[]',$row->bm_URL)."</td>"; ?> <?php echo "</tr>"; ?> <?php endforeach; ?> </table> <br /> <hr /> <?php echo anchor('site','Home'); ?> | <?php echo anchor('site/addbm','Add BM'); ?> | <?php echo anchor('site/delete','Delete BM'); ?> | <?php echo anchor('user/changepass','Change Password'); ?><br /> <?php echo anchor('site/recommend','Recommend URLs to me'); ?> | <?php echo anchor('user/logout','Log out'); ?><br /> Quote Link to comment https://forums.phpfreaks.com/topic/190340-ci-checkbox-for-deleting-rows/ Share on other sites More sharing options...
ram4nd Posted January 31, 2010 Share Posted January 31, 2010 You probably have your model wrong, check: http://codeigniter.com/user_guide/database/active_record.html#delete Quote Link to comment https://forums.phpfreaks.com/topic/190340-ci-checkbox-for-deleting-rows/#findComment-1004610 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.