Welcome Guest, Not a member yet? Register   Sign In
unable to update record
#2

Well, there are a few issues, but I can't be sure I've found any of the issues you're specifically looking for without a description of what's wrong (e.g. what you expect vs. what actually happens).

To start, though, remove the form elements from your edit view. You should not open a form then use the form_open() method inside the form, and you should use either form_close() or the </form> tag at the end of the form, not both. Also, if you want to display the result of $this->db->last_query() on your view, you should pass it from the controller instead of calling it directly in the view (it might work in the view, but there are a number of reasons it might not, so it should not be done).

Next, when using $this->db->set() and $this->db->update(), there's no reason to call $this->db->set($data) if you're passing $data to $this->db->update()'s second parameter. So your update method could look like this:

PHP Code:
public function update($data$old_roll_no)
{
    
$this->db->where("roll_no"$old_roll_no);
    
$this->db->update("stud"$data);


or you could chain the db calls:

PHP Code:
$this->db->where("roll_no"$old_roll_no)->update("stud"$data); 

If you really prefer the set() syntax, just omit $data from the update() call:

PHP Code:
$this->db->set($data)->where("roll_no"$old_roll_no)->update("stud"); 

Hopefully, the tutorial will eventually get around to adding form validation and other considerations, because you still wouldn't want to start using this code in production.
Reply


Messages In This Thread
unable to update record - by nadeem14375 - 07-27-2016, 11:16 AM
RE: unable to update record - by mwhitney - 07-27-2016, 11:57 AM
RE: unable to update record - by nadeem14375 - 07-27-2016, 12:18 PM
RE: unable to update record - by nadeem14375 - 07-27-2016, 12:20 PM
RE: unable to update record - by mwhitney - 07-28-2016, 10:35 AM
RE: unable to update record - by Wouter60 - 07-28-2016, 08:46 AM
RE: unable to update record - by jaynarayan - 07-30-2016, 10:36 AM
RE: unable to update record - by nadeem14375 - 07-30-2016, 11:14 AM
RE: unable to update record - by InsiteFX - 07-30-2016, 11:37 AM
RE: unable to update record - by nadeem14375 - 07-30-2016, 11:52 AM
RE: unable to update record - by nadeem14375 - 07-30-2016, 12:37 PM
RE: unable to update record - by Wouter60 - 07-30-2016, 11:08 PM
RE: unable to update record - by nadeem14375 - 07-31-2016, 02:18 AM
RE: unable to update record - by Wouter60 - 07-31-2016, 05:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB