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 8407173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:17:47+00:00 2026-06-09T23:17:47+00:00

I have a table name ‘payroll’ in my DB having the fields salary, bonus,

  • 0

I have a table name ‘payroll’ in my DB having the fields salary, bonus, overtime fields for employees. The salary of an employee is saved in the table. What i’m trying to do is to calculate the bonus field. That means if salary of an employee is lets say 2000 and bonus is 500 then in the “bonus” field it will be saved as 2500. Problem is that my code does not show any error but the field “overtime” is not updating in DB.
I’m using codigniter

my controller:

     function update_bonus(){
         $id=$this->input->post('id');
         $salary=$this->input->post('salary');
         $bonus=$this->input->post('bonus');
         $update=$salary+$bonus;
         $data['bonus']=$this->input->post('update');

         if ($this->pay->update_overtime($id,$data)==TRUE){
         $this->load->view('success');


         }
         else
                {
                $this->load->view('unsuccess');

                }
         }

    My model:

        function update_overtime($id,$data){
        $this->db->where('id', $id);
        $this->db->update('payroll', $data);
        if ($this->db->affected_rows() == '1')
        {
            return TRUE;
        }
        return FALSE;


    }
    }

The form:

echo form_open('payroll/update_bonus');?>
<p> Previous Salary was <? echo $info[0]->salary;?> .</p>
<p>
<?php echo form_hidden('id', $id, 'id="id'); ?>
</p>    
<p>
<?php echo form_hidden('id', $salary, 'id="salary'); ?>
</p> 

        <label for="bonus">Update Basic Salary <span class="required">*</span></label>
        <?php echo form_error('salary'); ?>
        <br /><input id="bonus" type="text" name="bonus"  value="<?php echo set_value('bonus'); ?>"  />
</p>


<p>
        <?php echo form_submit('submit', 'Submit'); ?>
</p>

<?php echo form_close(); ?>
  • 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-09T23:17:48+00:00Added an answer on June 9, 2026 at 11:17 pm

    You have got your variables and form element names mixed up –

    In your for view – you have got these hidden elements

    <?php echo form_hidden('id', $id, 'id="id'); ?>
    </p>    
    <p>
    <?php echo form_hidden('id', $salary, 'id="salary'); ?>
    </p> 
    

    I guess you wanted them to be –

    <?php echo form_hidden('id', $id, 'id="id'); ?>
    </p>    
    <p>
    <?php echo form_hidden('salary', $salary, 'id="salary'); ?>
    </p> 
    

    In your controller update_bonus() function

    $id=$this->input->post('id');
             $salary=$this->input->post('salary');
             $bonus=$this->input->post('bonus');
             $update=$salary+$bonus;
             $data['bonus']=$this->input->post('update');
    

    You are tying to use ‘update’ value from post data which was never set in your view file.

    I guess you you wanted $update=$salary+$bonus;
    $data['bonus']=$update;
    // I assume bonus is a database table column name and this is the only column you want to update in your model

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

Sidebar

Related Questions

I have table with following details Table name EMPLOYEE and columns EMPID (PK smallint
I have a table name wishlist . In this I have two fields user_id
I have a table name boards, and I'm trying to insert data using the
I'm trying to use composition in hibernate with annotations. I have: @Entity @Table(name =
I have a table name Data with fields Surmane , Name , Timestamp ,
I have a table name Overtime Hours which have the following columns Ot_ID, Shift_Date,
I have a table which have three fields ID,Name,aDate. I want result on distinct
I have table: id name type where type is 1 or 2 I need
I have a table name that starts with an underscore does that give any
I have a table (name, date, stat1, stat2, stat3) , (name, date) is the

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.