0

Resultado:

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;
}

2 respuestas 2

3

cambiar

$category = $cat["idcategory"];

por

$cat["idcategory"] = $category 
0

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

Debes declarar una variable antes de usarla.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.