Ver Mensaje Individual
  #6 (permalink)  
Antiguo 27/01/2014, 17:25
rakshaka
 
Fecha de Ingreso: mayo-2009
Mensajes: 166
Antigüedad: 15 años
Puntos: 2
Respuesta: Lista de Categorias y Subcategorias con una sola tabla.

$parent que valor tiene en el script?

function getTree($parent) {
$out = [];
$sql = "SELECT * FROM table WHERE parent_id = $parent";

while ($row = each_obj($items)) {
$out[$row->id] = [
'title' => $row->title,
'childs' => getTree($row->id)
];
}

return $out;
}

$all = getTree(0);