[eluser]Delvin[/eluser]
Hi there,
I am working on a school management system project and need some help in populating some query results in a dropdown menu.
Below is what I have done; I have queried the db and would need to pass these details to the view file in a 2 dimensional array.
$query = $this->db->query('SELECT Class_ID, First_Name, Middle_Name, Last_Name from student');
foreach ($query->result_array() as $row){
$temp = $row['Class_Name'];
$temp1 = $row['First_Name'].$row['Middle_Name'].$row['Last_Name'];
}
$data['Class_name']=$temp;
$data['Std_name']=$temp1;
$this->load->view('m_student/classlist_stdview.php',$data);
*********************************888
In the view file:
Select Class <select name="listclass" id="list_class>
<?php
foreach ($Class_name as $class){
echo "<option value=".$class.">".$class."</option>";
}
?>
</select>
Select Student <Select name="list_student">
<?php
foreach ($Std_name as $student){
if ( echo "[removed]getValue();[removed]" == $class) {
echo "<option value=".$student.">".$student."</option>";
}
}
?>
</Select>
**************************************888
When I print the value of the variable inside the for loop, it prints as 'Array'.
it would be of a great help if some one can guide me through the right path.
Regards,
Delvin