I have the following BD:
and what I want is to do a questionnaire in the following way:
Question 1
Question 2
I'm trying with the following code:
foreach ($data1 as $key)
{
if($key->idparent == 0 && $key->idevaluacion == 3)
{
echo "<h3>".$key->pregunta."</h3><br>";
foreach ($data1 as $key => $value) {
if($value->idparent == 1 && $value->idevaluacion == 3){
echo $value->pregunta."<br>";
}
}
}
}
But I need that $value->idparent == 1
(this one) is printed in a loop with the parents ID and I do not know how to do it.