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

  • Home
  • SEARCH
  • 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 6815939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:59+00:00 2026-05-26T20:51:59+00:00

So I’m new to PHP and MySQL generally, and MVC applications. Forgive me if

  • 0

So I’m new to PHP and MySQL generally, and MVC applications. Forgive me if this is a question that has been answered already, I couldn’t find anything that was crystal clear and showed the complete MVC flow of this.

So I have an HTML table full of inputs populated by data in a, I generate a form for each row as a separate table, and a submit button for each. I want the update button to update only the row associated with the generated form.

If remove this->db->where('id', $id); from the model it updates all rows in the table with the same info, with it present nothing is updated.

Any help or an alternative method for achieving this would be most appreciated. The controller function is also not pretty bad I think.

Thank you.

VIEW

<?php foreach($log->result() as $row): ?>
<?=form_open('hq/update_entry');?>
    <table class="editLog">
        <tr>
            <td><?php 
                $data = array(
                    'name' => 'no',
                    'value' => $row->no
                );
                echo form_input($data);
                ?></td>
            <td><?php 
                $data = array(
                    'name' => 'date',
                    'value' => $row->date
                );
                echo form_input($data);
                ?></td>
            <td><?php 
                $data = array(
                    'name' => 'artist',
                    'value' => $row->artist
                );
                echo form_input($data);
                ?></td>
            <td><?php 
                $data = array(
                    'name' => 'title',
                    'value' => $row->title
                );
                echo form_input($data);
                ?></td>
            <td><?php 
                $data = array(
                    'name' => 'long',
                    'value' => $row->long
                );
                echo form_input($data);
                ?></td>
            <td><?php 
                $data = array(
                    'name' => 'lat',
                    'value' => $row->lat
                );
                echo form_input($data);
                ?></td>
                <td>
            <?php
                echo form_hidden('id', $row->id);
                $data = array(
                    'class' => 'updateSubmit',
                    'value' => '✚'
                );
                echo form_submit($data);
            ?></td>
        </tr>
    </table>
<?=form_close();?>

CONTROLLER

function update_entry()
{
    $this->load->model('update_entry_model');

    if($query = $this->update_entry_model->update())
    {
        $this->index();
    }
    else
    {
        redirect('hq');
    }
}

MODEL

<?php
    class Update_entry_model extends CI_Model {
        function update()
        {
            $data = array(
                'no' => $this->input->post('no'),
                'date' => $this->input->post('date'),
                'artist' => $this->input->post('artist'),
                'title' => $this->input->post('title'),
                'long' => $this->input->post('long'),
                'lat' => $this->input->post('lat')
            );
            $this->db->where('id', $id);
            $this->db->update('entries', $data);
        }
    }
  • 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-05-26T20:51:59+00:00Added an answer on May 26, 2026 at 8:51 pm

    Without doing further investigation, I see that in the model function update(), you are missing

    $id = $this->input->post('id');
    

    The reason why adding this->db->where('id', $id); doesn’t update anything is because $id is not currently set to any value.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.