我有一个嵌套列表,用于显示来自数据库的可用视频,这些视频分组在各自的标题下。我想知道是否可以计算每个分组中的视频数量,以便我可以像这样显示它:
视频组标题 1(3 个视频)
1. 视频 1
2. 视频 2
3. 视频 3
视频组标题 2(6 个视频)
1. 视频 1
2. 视频 2
...等。
SQL 现在非常简单:
SELECT * FROM video_module_type;
我正在使用 ASP VBscript,我所拥有的代码是:
<%
'----------------------------------------------------------------------------------------------------
'VARIABLES
'----------------------------------------------------------------------------------------------------
Dim previous_video_module_name
Dim first_video_module_name
Dim DIV_vms_vid_title
Dim DIV_vms_grouping
Dim DIV_video_section_group
Dim DIV_vms_video_holder
Dim DIV_vms_sm_thumb
Dim DIV_vms_results
Dim vms_shim
Dim DIV_end
previous_video_module_name = ""
first_video_module_name = true
DIV_vms_vid_title = "<div class=""vms_vid_title"">"
DIV_vms_grouping = "<div id=""sustvid_webinar"" class=""vms_grouping"">"
DIV_video_section_group = "<div class=""video_section_group"">"
DIV_vms_video_holder = "<div class=""vms_video_holder"">"
DIV_vms_sm_thumb = "<div class=""vms_sm_thumb"">"
DIV_vms_vid_synopsis = "<div class=""vms_vid_synopsis"">"
DIV_vms_results = "<div class=""vms_results"">"
vms_shim = "<img src=""/images/shim.gif"" width=""16"" height=""16"">"
DIV_end = "</div>"
'----------------------------------------------------------------------------------------------------
'IF NOT THE SAME VALUE AS PREVIOUS
'----------------------------------------------------------------------------------------------------
for i = 0 to videoModulesListerNumber-1
if video_module_name(i) <> previous_video_module_name then
'------------------------------------------------------------------------------------------
'IF NOT THE FIRST TIME, CLOSE THE NESTED LIST
'------------------------------------------------------------------------------------------
if first_video_module_name then
response.Write("<h2>" & video_module_name(i) & "</h2>")
end if
'------------------------------------------------------------------------------------------
'DISPLAY THE CATEGORY
'------------------------------------------------------------------------------------------
response.Write("<!--START VIDEO GROUP: " & video_module_name(i) & "-->")
'------------------------------------------------------------------------------------------
'IF NOT THE SAME VALUE AS PREVIOUS OPEN THE NESTED LIST AND STORE THE CURRENT
'VALUE FOR COMPARISON NEXT TIME
'------------------------------------------------------------------------------------------
previous_video_module_name = video_module_name(i)
end if
'------------------------------------------------------------------------------------------
'DISPLAY THE VIDEOS
'------------------------------------------------------------------------------------------
response.Write(DIV_vms_grouping)
response.Write(DIV_video_section_group)
response.Write(DIV_vms_video_holder)
response.Write(DIV_vms_vid_title & "<h2>" & video_module_video_name(i) & "</h2>" & DIV_end)
response.Write(DIV_vms_sm_thumb & video_module_thumbnail(i) & DIV_end)
response.Write(DIV_vms_vid_synopsis)
response.Write("<p>" & video_module_synopsis(i) & "</p>")
response.Write(DIV_vms_results & vms_shim & DIV_end)
response.Write(DIV_end) ' close DIV_vms_grouping
response.Write(DIV_end) ' close DIV_video_section_group
response.Write(DIV_end) ' close DIV_vms_video_holder
'------------------------------------------------------------------------------------------
'IT'S NO LONGER THE FIRST TIME; CHANGE THE "first_video_module_name" VARIABLE
'------------------------------------------------------------------------------------------
first_video_module_name = false
next
%>
我认为问题可能是我不知道这个术语是什么,所以我无法搜索它,但任何帮助将不胜感激。