Add two fields, one is the parent ID, if it is the top level, the parent ID is 0, the other is whether there are subordinates, 0 yuan 1 yes, a function can solve it, call this function in the middle of the function, find out the parent layer, Then look for whether he has subordinates. If so, look for the column whose parent ID is the primary ID.
'================================================== =
'Process name: listecityclass
'Function: Display system classification
'Parameter: id ------ System ID to be matched
'================================================== =
Sublistecityclass(id)
dim F_reco,F_total,F_n,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject(ADODB.Recordset)
F_reco.Open select classid,classname,classlayer from ws_ecityclass where classparent=0 and classlist=0 order by classorder Asc,conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
format_i=1
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
response.write <option
if F_classlayer=0 then response.write value= & F_classid
if id=F_classid then response.write selected
response.write > & F_classname & </option>
if F_classlayer=1 then call listecityclass_(id,F_classid) 'Call another function, below
F_reco.movenext
next
end if
F_reco.close : set F_reco=nothing
End Sub
Sub listecityclass_(id,iid)
dim F_reco,F_total,F_n,F_m,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject(ADODB.Recordset)
F_reco.Open select classid,classname,classlayer from ws_ecityclass where classparent=&iid& and classlist=0 order by classorder Asc,conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
format_i=format_i+1
response.write <option
if F_classlayer=0 then response.write value= & F_classid
if id=F_classid then response.write selected
response.write >
for F_m=format_i to 2 step -1
response.write
if F_m=2 then
if F_n=F_total then response.write └ else response.write ├
end if
next
response.write F_classname & </option>
if F_classlayer=1 then call listecityclass_(id,F_classid) 'Call this function
F_reco.movenext
format_i=format_i-1
next
end if
F_reco.close : set F_reco=nothing
End Sub