Welcome Guest, Not a member yet? Register   Sign In
Repeating Tasks Without Repeating Projects
#1

[eluser]jshultz[/eluser]
Here's the link to the code: http://stikked.com/view/8550586

It's repeating the project over and over, and I would like for it to just show the project once and then the associated tasks below it.

I'm just not sure how to accomplish that though.

Would there be a way to loop through the join data to just show the tasks without reprinting the project name?
#2

[eluser]garymardell[/eluser]
You will need to pass through a limit $this->db->limit(1);
Also seems your get tasks by id has no id to work with.

That function tasksByProjectId() is always going to return all the projects.
#3

[eluser]jshultz[/eluser]
How would that ($this->db->limit(1)Wink work? I understand what it does, but I want to cycle through all the projects and their associated tasks. I would just like the tasks to be listed under each project without it repeating the same project over and over.

In other words I want:

project
-task
-task
project 2
-task
project 3
project 4
-task
-task
-task

instead, i'm getting
project
-task
project
-task
project 2
etc.
etc.
etc.
#4

[eluser]garymardell[/eluser]
Oh sorry, i thought you meant that you just wanted to show one project. My bad.
You will probably have to create a temporary array using the id as the array index.
#5

[eluser]jshultz[/eluser]
that's exactly what I ended up doing and it worked. thanks. Smile

Here's the code thanks to ignitedcoding on the IRC channel:

Code:
<?php $currentProjectID = NULL; ?>        
<?php foreach ($projectPlusTasks as $row): ?>
        <?php if ( $currentProjectID != $row->projectid ): ?>
        <tr>
            <td>
                <strong>Project:</strong>
                &lt;?= $row->projectid?&gt;
            </td>
            <td>
                &lt;?= $row->project_name?&gt;
            </td>
            <td>
                &lt;?= $row->p_due_date?&gt;
            </td>
            <td>
            </td>
        </tr>
        &lt;?php endif;?&gt;
        <tr>
            <td>
                <strong>Task:</strong>
                &lt;?= $row->taskid?&gt;
            </td>
            <td>
                &lt;?= $row->task?&gt;
            </td>
            <td>
                &lt;?= $row->t_due_date?&gt;
            </td>
            <td>
            </td>
        </tr>
        &lt;?php $currentProjectID = $row->projectid; ?&gt;
        &lt;?php endforeach; ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB