Tema: Menu web
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/02/2005, 15:45
Avatar de sjam7
sjam7
 
Fecha de Ingreso: diciembre-2001
Ubicación: Guadalajara, Mexico
Mensajes: 3.672
Antigüedad: 23 años, 6 meses
Puntos: 16
bueno, tengo una tabla que tiene 3 campos:
id_categoria : consecutivo autonumerico
categoria : texto, nombre de la categoria ej: "PRODUCTOS"
parentid : numerico, indica a que menu pertenece, si es principal el valor es 0

despues con el siguiente codigo haces el arbol:

Código:
<%
Call DoTree(0,0)

Sub DoTree(ParentID, intLevel)
RSc = Server.MapPath("bd.mdb")
Set conexion = Server.CreateObject("ADODB.Connection")
conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & RSc & ";"
Set RSc = Server.CreateObject("ADODB.Recordset")

if categ<>"" then
en=0
else
en=categ
end if


SQLQ = "SELECT * FROM categorias WHERE ParentID = "&parentid&" ORDER BY categoria ASC"
	   RSc.Open sqlq, conexion,1,1
	   If Not rsc.EOF Then 
		   Do while not rsc.EOF 
				 Response.Write Replace(Space(intLevel), " ", "&nbsp;&nbsp;&nbsp;&nbsp;")
Response.Write "•<a href=agregacat.asp?categ="&rsc("id_categoria")&">"&rsc("categoria")&"</a> <A HREF=borrac.asp?tabla=categorias&id="&rsc("id_categoria")&"></a><br>" 
			    DoTree rsc("id_categoria"), intLevel + 1 
			   rsc.MoveNext 
		   Loop 
	   End If 
	   rsc.Close 
	   Set rsc = Nothing 
End Sub 
'------------------------------------------------------------ 
%>
Pruebalo y me comentas si te sirvio
__________________
CreandoWebs.com
www.creandowebs.com
PLANTILLAS TEMPLATEMONSTER CON 10% DE DESCUENTO

Última edición por sjam7; 02/02/2005 a las 15:46