Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/02/2011, 19:24
Avatar de masterpuppet
masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 17 años
Puntos: 845
Respuesta: Ayuda con indentacion recursiva en categorias

Lo único que tenes que hacer es pasarle por parámetro el nivel a tu función, y utilizar str_repeat, algo asi:

Código PHP:
Ver original
  1. function getAllCategories($id_parent = 0, $deep = 0){
  2.     $sql = mysql_query("SELECT * FROM `sys_categories` c INNER JOIN `sys_categories_lang` cl ON (c.`id_category`=cl.`id_category`) WHERE c.`parent`=".intval($id_parent)."  ORDER BY c.`id_category` ASC");
  3.     $result = array();
  4.     while($cat = mysql_fetch_assoc($sql)){
  5.        echo str_repeat('&nbsp;', $deep) . $cat['name'].'<br />';
  6.        getAllCategories($cat['id_category'], $deep++);
  7.     }
  8. }
  9. getAllCategories();


Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)