注册 登录
编程论坛 ASP技术论坛

字段按字母排序问题

wuchunyu120 发布于 2008-08-12 10:12, 1010 次点击
同题:
现有一个无限分类下拉菜单 是按照类别ID排列的
如何在原有基础上不改变分类布局的情况下  把其中的小类按照名称的字母方式排序?
代码如下:
程序代码:
<table width="190" border="0" align="center" cellpadding="0" cellspacing="0">
               <%
                                    strcode=""
                                    for i=1 to Len(SourCode) \ 4
                                    strcode=strcode&" or c_code like '"&left(SourCode,i*4)&"____'"
                                    next
                                    if strcode<>"" then
                                    strcode="(1<>1"&strcode&" or Len(c_code)=4)"
                                    else
                                    strcode=" Len(c_code)=4"
                                    end if
                                    strSQL="Select * From web_news_class Where 1=1 and " & strcode & "  Order by c_code"
                                    'response.Write(strsql)
                                    Set rs=Server.CreateObject("ADODB.RecordSet")
                                    rs.open strSQL,conn,1,1
                                    for i=1 to rs.recordcount
                                    Level=(Len(rs("c_code"))/4-1)*3
                                    If Len(rs("c_code"))>4 then
                                    mefeekk="this.className='highlight1'"
                                    else
                                    mefeekk="this.className='highlight'"
                                    end if
                                    %>
            
            <% If Len(rs("c_code"))>4 Then %>
            <tr>
              <td height="25" bgcolor="#FFFFFF"  >
              <% select case  Len(rs("c_code"))
              case 12
              
              %>
              &nbsp;&nbsp;
              <% case 16 %>
              &nbsp;&nbsp;&nbsp;&nbsp;
              <% end select %>
<% bpk=conn.execute("select count(*) from [web_news_class] where c_name='"&rs("c_name")&"'")(0) %>
              <a href="product.asp?class=<%=rs("id")%>&classname=<%=trim(rs("c_name"))%>"><% If bpk>0 Then %><IMG src="image/11111.gif" width="20" height="19" border=0 align="absbottom"><% Else %><img src="pic/05.gif">
<% End If %>
<%=trim(rs("c_name"))%></a>              </td></tr>
             <% Else %>
              <tr>
              <td height="25" bgcolor="#FFFFFF"  class="w2" >
            
               <img src="to_class3.gif"  align="absmiddle">&nbsp;&nbsp;<a href="product.asp?class=<%=rs("id")%>&classname=<%=trim(rs("c_name"))%>"><strong><%=trim(rs("c_name"))%></strong></a>  </td>
              </tr>
   <tr>
              <td height="1" background="pic01/011.jpg">  </td></tr>


<% End If %>

            <%
                                        rs.movenext
                                    next
                                    %>
        </table>
1 回复
#2
madpbpl2008-08-12 10:16
SELECT * FROM [tb] ORDER BY 排序的字段 COLLATE chinese_PRC_CS_AS_KS_WS
1