[eluser]reghan[/eluser]
Hello,
I am new to code igniter. I am trying to create links for a bunch of different departments. When the user clicks on a link I would like that departments info to be produced in a view. So far I am just getting errors.
here is my code. Any advice would be greatly appreciated!
Controller:
Code:
<?php
class Bia extends CI_Controller
{
function Bia()
{
parent::__construct();
$this->load->model('department_model');
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('form_helper');
$this->load->library('form_validation');
$this->load->library('table');
}
function index()
{
$this->db->order_by('DepartmentName', 'asc');
$query['depart_list'] = $this->db->get('department');
$this->load->view('bia_home', $query);
}
function get_depart_info() //gets the department info based on the Id number.
{
$id = $this->uri->segment(3);
$this->db->where('DepartmentId', $id);
$query['dept_info'];
$this->load->view('dept_info', $query);
}
}
?>
view # 1:
Code:
<table border="1">
<tr>
<th>Department</th>
<th>Responder</th>
<th>Last Updated</th>
</tr>
<?php foreach($depart_list->result() as $row): ?>
<?php echo "<tr>"; ?>
<?php echo "<td>". anchor('bia/get_dept_info/'.$row->DepartmentId, $row->DepartmentName, 'id="'.$row->DepartmentId.'"') ."</td>"; ?>
<?php echo "<td>". $row->Responder ."</td>"; ?>
<?php echo "<td>". $row->DateCompleted ."</td>"; ?>
<?php echo "</tr>"; ?>
<?php endforeach; ?>
</table>
view #2
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<h3>Business Impact Analysis(BIA) Questionnaire</h3>
<p>The Business Impact Analysis (BIA) is a process
to determine the mission critical business functions and
associated critical resources. This will be accomplished for
Manitoba Lotteries by completing the following six components:
</p>
<?php if($depart_list->num_rows() == 0): ?>
<p>There are no Departments to List</p>
<?php else: ?>
<table border="1">
<tr>
<th>Department</th>
<th>Responder</th>
<th>Last Updated</th>
</tr>
<?php foreach($depart_info->result() as $row): ?>
<?php echo "<tr>"; ?>
<?php echo "<td>". $row->Responder ."</td>"; ?>
<?php echo "<td>". $row->DateCompleted ."</td>"; ?>
<?php echo "</tr>"; ?>
<?php endforeach; ?>
</table>
<?php endif; ?>
</body>
</html>
So basically view #1 lists all the departments and some info. when the link is clicked I would like to store the department Id and produce View #2 which only shows department info based on the Id of the link clicked. Again I am super new to codeignitor and I know this should be easy, but I just dont understand!
Thanks for the help!