Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:57:48+00:00 2026-06-11T13:57:48+00:00

I am using uri segment to delete info in my database: anchor(‘site/delete_note/’.$row->id, ‘Delete’) Model:

  • 0

I am using uri segment to delete info in my database:

anchor('site/delete_note/'.$row->id, 'Delete')

Model:

function delete_note()
{
    $this->db->where('id', $this->uri->segment(3));
    $this->db->delete('note');
}

It works fine, but I want to do the same for updating my info and can’t get it work
So this is link in view:

anchor('site/edit_note/'.$row->id, 'Edit')  

My controller:

function edit_note()
{
    $note_id = $this->uri->segment(3);
    $data['main_content'] = 'edit_note';
    $this->load->view('includes/template', $data);

    $this->load->library('form_validation');

    $this->form_validation->set_rules('content', 'Message', 'trim|required');


    if($this->form_validation->run() == TRUE)
    {
        $this->load->model('Note_model');
        $this->Note_model->edit_note($note_id);
        redirect('site/members_area'); 

    }

}

My model:

function edit_note($note_id)
{
    $content = $this->input->post('content');
    $data = array('content' => $content);
    $this->db->where('id', $note_id);
    $this->db->update('note', $data);
}

My view of edit_note:

<?php

    echo form_open('site/edit_note');
    echo form_textarea('content', set_value('content', 'Your message'));

    echo form_submit('submit', 'Change');
    echo anchor('site/members_area', 'Cancel');


    echo validation_errors('<p class="error">');        ?>

Edit doesn’t work as delete, when i am trying to get segment directly in edit model, as I used in delete model.

If I set $note_id to a number in my controller, instead of this ‘$this->uri->segment(3)’, it updates my database. But if I use getting segment it doesn’t work. I thought uri segments are available in controller as in model, but there is something I don’t know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:57:50+00:00Added an answer on June 11, 2026 at 1:57 pm

    Better yet, instead of manually reading the IDs via the segments, you could change your functions to be:

    function delete_note($note_id)

    and

    function edit_note($note_id)

    And remove the $note_id = $this->uri->segment(3); lines.

    And as silly as it’ll sound, the generated URL is definitely correct, right?

    And last question, have you done anything with routes?

    Edit

    I’ve also noticed that in edit, you use this in your form:

    echo form_open('site/edit_note');

    So when the form submits, the URL it submits to is site/edit_note instead of site/edit_note/{SOME_ID}. So once you make your changes, and the form submits, there won’t be a 3rd URL segment!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$this->db->from('posts'); $this->db->where('id',$this->uri->segment(3)); $data['query'] = $this->db->get(); I am trying to get one post using a
I'm using the codeigniter framework and utilizing the uri->segment(); function I have an array:
My domain model is using System.Net.Uri to represent URLs, and System.Drawing.Color to represent colors.
What is the safest way to delete rows in a database table using Codeigniter?
Working on a submit function from a jQuery dialog (based on this question). Using
I am attempting to print a JPEG file that I reference using a Uri
using <?php echo $_SERVER['REQUEST_URI'] ;?> when the url is: www.site.com/a/b/c/#d does not show the
I'm using Nokogiri and open-uri to grab the contents of the title tag on
Im using this code: protected String getContactInfo() { Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, null,
How can I translate whole URI in routes using I18n? Example: (CZ URI =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.