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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:30:38+00:00 2026-06-09T14:30:38+00:00

I am have a bit of an issue that I need some pointers on

  • 0

I am have a bit of an issue that I need some pointers on if someone can help me please.

I am using CodeIgniter and need to display the client name, job name and task for each row on the timesheet list daily times are editable in the list but the 3 fields above are static. Currently i display the id of the client, job and task that are stored in the timesheetEntries table but i need to display the correct names from the seperate tables in each row on the timesheet Entries.

In its current state it returns corretc results and works well apart from the linking to the other tables.

I am going out of my mind on this one as i can’t find the solution and am now suffering from code blindness.

Many Thanks

Model

function getAllEntriesByTimesheet($id){
    $data = array();
    $options = array('timesheet_id' => $id);
    $Q = $this->db->get_where('timesheetEntries', $options);
    if ($Q->num_rows() > 0){
        foreach ($Q->result_array() as $row){
            $data[] = $row;
        }
    }
    $Q->free_result();    
    return $data; 
}  

Controller

function id($id){
    $data['title'] = 'Timesheets';
    $data['entry'] = $this->timesheet_model->getAllEntriesByTimesheet($id);
    $data['sheet'] = $this->uri->segment(3);
    $data['header'] = 'default/header';
    $data['main'] = 'timesheet_view';
    $data['footer'] = 'default/footer';
    $data['timesheettab'] = 'current';
    $data['expensestab'] = '';
    $data['holidaytab'] = '';
    $data['admintab'] = '';
    $this->load->vars($data);
    $this->load->view('default/default_view');
}

View

$datestring = '%Y-%m-%d';
if (count($entry)){
    foreach ($entry as $key => $list){
        $dateNow = mdate($datestring);
        $entryId = $list['entry_id'];
        $sheet = $list['timesheet_id'];
        $clientId = $list['client_id'];
        $jobId = $list['job_id'];
        $taskId = $list['task_id'];
        $fridayHrs = $list['friday_hrs'];
        $saturdayHrs = $list['saturday_hrs'];
        $sundayHrs = $list['sunday_hrs'];
        $mondayHrs = $list['monday_hrs'];
        $tuesdayHrs = $list['tuesday_hrs'];
        $wednesdayHrs = $list['wednesday_hrs'];
        $thursdayHrs = $list['thursday_hrs'];
        echo '<tr>'
            .form_open('/timesheet/update_entry')
            .form_hidden('entry_id', $entryId)
            .form_hidden('timesheet_id', $sheet)
            .form_hidden('date_modified', $dateNow).
            '<td>'.$clientId.'</td>
            <td>'.$jobId.'</td>
            <td>'.$taskId.'</td>
            <td class="studio">'.form_input('monday_hrs', $mondayHrs).'</td>
            <td class="studio">'.form_input('tuesday_hrs', $tuesdayHrs).'</td>
            <td class="studio">'.form_input('wednesday_hrs', $wednesdayHrs).'</td>
            <td class="studio">'.form_input('thursday_hrs', $thursdayHrs).'</td>
            <td class="studio">'.form_input('friday_hrs', $fridayHrs).'</td>
            <td class="studio">'.form_input('saturday_hrs', $saturdayHrs).'</td>
            <td class="studio">'.form_input('sunday_hrs', $sundayHrs).'</td>
            <td class="icon">'.form_submit('', 'Update','class="update"').'</td>
            <td class="icon"><a href="/timesheet/edit_entry/'.$sheet.'/'.$entryId.'"><img src="/images/sitewide/edit.png" alt="Edit Entry" width="24" height="24" /></a></td>
            <td class="icon"><a href="/timesheet/delete_entry/'.$sheet.'/'.$entryId.'"><img src="/images/sitewide/delete.png" alt="Delete Entry" width="24" height="24" /></a></td>'
            .form_close()
            .'</form></tr>';    
    }
}

These are the database table schema for related tables

tasks

+------------------+-------------------+--------+------+----------+--------+
| Field            | Type              | Null   | Key  | Default  | Extra  |
+------------------+-------------------+--------+------+----------+--------+
| task_id          | int(4) unsigned   | NO     | PRI  | NULL     | AI     |
| task_name        | varchar(100)      | NO     |      | NULL     |        |
| task_type        | int(2)            | NO     |      | 2        |        |
| task_code        | varchar(10)       | NO     |      | NULL     |        |
+------------------+-------------------+--------+------+----------+--------+

clients

+------------------+-------------------+--------+------+----------+--------+
| Field            | Type              | Null   | Key  | Default  | Extra  |
+------------------+-------------------+--------+------+----------+--------+
| client_id        | int(4) unsigned   | NO     | PRI  | NULL     | AI     |
| client_name      | varchar(100)      | NO     |      | NULL     |        |
+------------------+-------------------+--------+------+----------+--------+

jobs

+------------------+-------------------+--------+------+----------+--------+
| Field            | Type              | Null   | Key  | Default  | Extra  |
+------------------+-------------------+--------+------+----------+--------+
| job_id           | int(6) unsigned   | NO     | PRI  | NULL     | AI     |
| job_number       | varchar(6)        | NO     |      | NULL     |        |
| client_id        | int(4)            | NO     |      | NULL     |        |
| job_name         | varchar(100)      | NO     |      | NULL     |        |
| create_date      | date              | NO     |      | NULL     |        |
| start_date       | date              | NO     |      | NULL     |        |
| account_handler  | varchar(4)        | NO     |      | NULL     |        |
| studio_resource  | varchar(4)        | NO     |      | NULL     |        |
| action           | varchar(50)       | NO     |      | NULL     |        |
| by_whom          | varchar(10)       | NO     |      | NULL     |        |
| deadline         | date              | NO     |      | NULL     |        |
| job_status       | varchar(50)       | NO     |      | NULL     |        |
+------------------+-------------------+--------+------+----------+--------+

timesheetEntries

+------------------+-------------------+--------+------+----------+--------+
| Field            | Type              | Null   | Key  | Default  | Extra  |
+------------------+-------------------+--------+------+----------+--------+
| entry_id         | int(10) unsigned  | NO     | PRI  | NULL     | AI     |
| user_id          | int(10)           | NO     |      | NULL     |        |
| timesheet_id     | int(5)            | NO     |      | NULL     |        |
| client_id        | int(4)            | NO     |      | NULL     |        |
| job_id           | int(4)            | NO     |      | NULL     |        |
| task_id          | int(2)            | NO     |      | NULL     |        |
| monday_hrs       | decimal(4,2)      | NO     |      | 0.00     |        |
| tuesday_hrs      | decimal(4,2)      | NO     |      | 0.00     |        |
| wednesday_hrs    | decimal(4,2)      | NO     |      | 0.00     |        |
| thursday_hrs     | decimal(4,2)      | NO     |      | 0.00     |        |
| friday_hrs       | decimal(4,2)      | NO     |      | 0.00     |        |
| saturday_hrs     | decimal(4,2)      | NO     |      | 0.00     |        |
| sunday_hrs       | decimal(4,2)      | NO     |      | 0.00     |        |
| total_hrs        | decimal(4,2)      | NO     |      | 0.00     |        |
| date_entered     | date              | NO     |      | 0.00     |        |
| date_modified    | date              | NO     |      | 0.00     |        |
+------------------+-------------------+--------+------+----------+--------+

Solution

Provided by András Rátz

Model

function getAllEntriesByTimesheet($id){
    $data = array();
    $this->db->select('*');
    $this->db->join('tasks', 'tasks.task_id = timesheetEntries.task_id', 'left');
    $this->db->where('timesheetEntries.timesheet_id',$id);
    $Q = $this->db->get('timesheetEntries');
    if ($Q->num_rows() > 0){
        foreach ($Q->result_array() as $row){
            $data[] = $row;
        }
    }
    $Q->free_result();    
    return $data; 
} 

the View need to have the variable

$taskId = $list['task_id']; 

changed to

$taskId = $list['task_name'];

sorted thanks 🙂

  • 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-09T14:30:40+00:00Added an answer on June 9, 2026 at 2:30 pm

    Because you didn’t wrote the table names, here is an example. You need to change your model.

    $this->db->select('*');
    $this->db->from('timesheetEntries');
    $this->db->join('otherTable', 'otherTable.id = timesheetEntries.taskId', 'left');
    $this->db->where('timesheetEntries.timesheet_id',$id);
    $Q = $this->db->get();
    

    In $this->db->get(), leave blank the get part, because with from, you already selected the table.
    Without the exact table structure, it’s hard to write the correct syntax.

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

Sidebar

Related Questions

I need some help. I'm looking to have a sidebar that toggles when a
I'm having a bit of an issue that I'd appreciate some help with. I
I have a slight issue that someone might be able to point me in
I've got a bit of a usability issue that I'd value some input on.
I have a bit of an issue with my SQL statement. It is a
I have a bit of an issue with a site I maintain. I have
I am having a bit of a issue. I have an NSMutableDictionary with 10
hello fellow java developers. I'm having a bit of an issue here. I have
I have run into a bit of a design issue with my code. I
I am having a bit of a strange issue. I have a ListView which

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.