[eluser]adelregh[/eluser]
Hi guys,
I am very new to codeigniter. I am trying to send a query from the controller to the view. I have to different functions with two different queries. How can I style the two different results in the single view I have?
Does that make sense?
here is my code in the controller:
Code:
public function publications()
{
$query = $this->db->query('SELECT P_ID, TITLE FROM publications WHERE SSN = 1;');
$data['name'] = 'publications';
$data['section'] = "Publication";
$data['query'] = $query;
$this->load->view('adel', $data);
}
public function teaching()
{
$query = $this->db->query('SELECT C_ID, DEP_CODE, C_NAME, C_DESC FROM TEACHING WHERE SSN = 1;');
$data['name'] = 'teaching';
$data['section'] = "Teaching";
$data['query'] = $query;
$this->load->view('adel', $data);
}
here is my code in the view:
Code:
<div class="col-lg-12">
<h1> <?=$section ?> </h1>
<?php
if ($name = 'publications')
{
foreach ($query->result() as $row)
{
echo $row->P_ID;
echo ": ";
echo $row->TITLE;
echo "<br>" . "<br>";
}
}
elseif ( $name = 'teaching')
{
foreach ($query->result() as $row)
{
echo $row->DEP_CODE;
echo $row->C_ID;
echo " ";
echo $row->C_NAME;
echo "<br>" . "Course Description: <br>";
echo $row->C_DESC;
}
}
?>
</div>
any help would greatly appreciated