-1

次の表があります。

Name    Type    Color    Place
Ana     A       Blue     America
Sandra  A       Red      India
Mary    A       Red      America
Paige   B       Orange   Africa
Fox     B       White    Africa
John    C       Black    Mexico

次のように、アイテムをタイプとショーでグループ化したいと思います。

Type A
Ana - Blue - America
Sandra - Red - India
Mary - Red - America

Type B
Paige - Orange - Africa
Fox - White - Africa

Type C
John - Black - Mexico

これにはどのようなループが役立ちますか?

ありがとう!

4

2 に答える 2

1

タイプ別に並べ替えてレコードを選択し、レコードセットをループするだけです。

変数のタイプを追跡し、タイプが変更されるたびに、次のタイプを書き出す前に改行を追加します。

編集:例:

<%
    Dim strType

    do while not rs.EOF
        if strType <> rs("Type") then  ' <---- check if the types are different here
            Response.Write "Type " & rs("Type") & "<BR><BR>"
        end if

        ' your user records go here

        strType = rs("Type")  ' <---- set the strType variable before looping
        rs.MoveNext
   loop
%>
于 2012-09-13T17:40:16.540 に答える
0
select Name, Color, Place 
from MyTable
order by Type

次に、ASP コードで、Type 値が前の Type と同じでない (または最初の行である) 場合、Type ヘッダー行を出力します。

于 2012-09-13T17:39:23.647 に答える