Result:
Notice: Undefined variable: cat in C: \ xampp \ htdocs \ DSagredo \ forums.php on line 18
Notice: Undefined variable: cat in C: \ xampp \ htdocs \ DSagredo \ forums.php on line 20
SELECT * FROM forums WHERE idcategory =
Fatal error: Call to a member function fetch_assoc () on boolean in C: \ xampp \ htdocs \ DSagredo \ inc \ link.class.php on line 62
index.php
$obj = new DSagredo();
$categories = $obj->getCategories();
foreach ($categories as $category)
{
$category = $cat["idcategory"];
echo $cat["category"];
$foros = $obj->getForums($category);
}
link.class.php
function getForums($categoria)
{
echo $sql = "SELECT * FROM forums WHERE idcategory =". $categoria;
$res = $this->mysqli->query($sql);
while($row = $res->fetch_assoc())
{
$data[] = $row;
}
/*if(isset($data)){
return $data;
}*/
return $data;
}