I have the following function
function get_isub_category($parid)
{
$this->table = "ibf_gallery_categories";
$this->query = mysql_query("SELECT id, name FROM $this->table WHERE parent = '$parid'");
while ($this->result = mysql_fetch_array($this->query))
{
global $id, $category;
$id[] = $this->result -> id;
$category[] = $this->result -> name;
}
}
If I print_r ($category), the correct number of elements are returned but not the values.
I am trying to list the values with a for loop or a foreach loop but the results will not print.
However, if I run this function
function get_isub_category($parid)
{
$this->table = "ibf_gallery_categories";
$this->query = mysql_query("SELECT id, name FROM $this->table WHERE parent = '$parid'");
while ($this->result = mysql_fetch_array($this->query))
{
global $id, $category;
$id = $this->result['id'];
$category = $this->result['name'];
}
}
and print $category, I get only the last value. So I know the values are there. But why will they not print within the array?