[eluser]spmckee[/eluser]
Greetings,
This is my first dive into CI and am loving it but running into a small snag. I can get the whole "Works Table" array and pass it on to the view for display but I need to change the values of "task_1, task_2 and task_3" into the names from the "Task Table", which is currently not happening.
Any help is greatly appreciated.
Thanks!
Works Table:
+++++++++++++++++++++++++++++++++++++++++++++++
ID name task_1 task_2 task_3
----------------------------------------------
1 Nike 1 3 3
2 Dell 3 1 5
3 IBM 4 2
+++++++++++++++++++++++++++++++++++++++++++++++
Task Table:
++++++++++++++
ID name
--------------
1 Design
2 Development
3 Research
4 Concepting
++++++++++++++
The Model
Code:
class MOurWork extends My_Model{
function MOurWork(){
parent::My_Model();
}
function getAllWorks(){
$data = array();
$query = $this->db->query('SELECT * FROM works WHERE active="1"');
if ($query->num_rows() > 0){
foreach ($query->result_array() as $row){
$data[] = $row;
}
}
$query->free_result();
return $data;
}
}
The Controller
Code:
<?php
class Our_work extends My_Controller {
function our_work()
{
parent::My_Controller();
}
function index()
{
$data['main'] = 'our_work';
$data['works'] = $this->MOurWork->getAllWorks();
$this->load->view('template', $data);
}
}
?>
The View
Code:
<div class="works-thumbs-container">
<?php
if (count($works)){
foreach ($works as $key => $list){
?>
<div class="works-thumb">
<a href="#" title="<?php echo $list['desc_short']; ?>">
<img class="img-web-thumb" alt="<?php echo $list['project_name']; ?> Thumbnail" src="images/works/<?php echo $list[" />
</a>
<div class="tooltip">
<p>This is a small Tooltip with the Classname 'Tooltip'</p>
</div>
<p>
<ul>
<?php
for ($i = 1; $i < 3; $i++)
{
$task_key_name = 'task_name_'.$i;
if ($list[$task_key_name]!='NULL'){ echo '<li>'.$list[$task_key_name].'</li>'; }
}
?>
</ul>
</p>
<p><?= $list['project_name']; ?></p>
</div>
<?php
}
}
?>
</div>