Jump to content

Recommended Posts

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 />

 

Link to comment
https://forums.phpfreaks.com/topic/190340-ci-checkbox-for-deleting-rows/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.