[eluser]clintonbeattie[/eluser]
Hi,
I have some code but it only lists the first item in a database table and not all of them.
I have used print_r($data), as you'll see below in the model, but just get "Array ( [id] => 1 [cat_name] => Search Engine Optimisation )"
Any help greatly appreciated!
CONTROLLER
Code:
function getCategoriesNav(){
$data = array();
$this->db->select('id,cat_name');
$this->db->from('category');
$Q = $this->db->get();
if($Q->num_rows() > 0) {
$data = $Q->row_array();
print_r($data);
}
$Q->free_result();
return $data;
}
VIEW
Code:
if (count($category_navigation)){
echo "<ul>";
foreach ($category_navigation as $id => $cat_name){
echo "<li>";
echo anchor("welcome/category/$id",$cat_name);
echo "</li>";
}
echo "</ul>";
}
MODEL
Code:
function getCategoriesNav(){
$data = array();
$this->db->select('id,cat_name');
$this->db->from('category');
$Q = $this->db->get();
if($Q->num_rows() > 0) {
$data = $Q->row_array();
print_r($data);
}
$Q->free_result();
return $data;
}