Hi, i am creating a simple blog, which i have a function like this
PHP Code:
<?php
function get_category($id=null){
//displaying categories is better to store it in an array
$categories=array();
$query=mysql_query("SELECT `id`,`name` FROM `categories`");
while($rows=mysql_fetch_assoc($query)){
$categories[]=$rows;
}
return $rows;
}
?>
which will display my blog topic category post at category_list.php
Now i loop through using a foreach loop ,here is the code
PHP Code:
<?php
foreach(get_category() as $category){
echo $category['name'].'<br/>';
}
?>
Now it given me this error
! ) Warning: Invalid argument supplied for foreach() in C:\wamp\www\blog\category_list.php on line 12
Call Stack
Can some help me on how to loop through that function on the top.
Thanks
Clement OSei