如果在循环中停止出现相同的名称

时间:2015-12-23 04:00:57

标签: loops if-statement filter distinct

我有页面显示在场地中表演的艺术家,如果他们有未来的日期,他们是粗体文字,如果他们没有未来日期,他们是灰色文本。如果有未来日期,我不需要显示非未来日期,因此行为名称仅在列表中显示一次,作为将来或未来格式化。我无法过滤掉sql,因为它没有显示所有的行为。

难倒!!!请帮助display of page here

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="functions.asp"-->
<%
strVenue = Request.Form("Venue")
strContact = Request.Form("Venue")
iDate = DATEADD("yyyy", -1, Date())
iDate2 = DATEADD("yyyy", +1, Date())
strcheck = "outerphase"

Set objconn = Server.CreateObject("ADODB.Connection")
objconn.ConnectionString = "DRIVER=xxx; SERVER=xxx; PORT=xxx; DATABASE=xxx; UID=xxx; PASSWORD=xxx; OPTION=xxx"    
objconn.Open

Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT `ActName`, `CustomBanner` FROM `Contacts` WHERE         Contact='"&strContact&"' "
objRS.Open strSQL, objconn

strA = objRS("ActName")
StrBanner = objRS("CustomBanner")

If StrBanner = "" then
StrBanner = "banner.jpg" 
else
StrBanner = StrBanner
End if
%>

<body BGCOLOR="#000000" TEXT="#000000"  LEFTMARGIN="0" TOPMARGIN="0"     MARGINWIDTH="0" background="xxx" MARGINHEIGHT="0" rightmargin="0"     bottommargin="0" style="text-align: center">
<div align="center">
<br><br>

<%
DtStart = WKStart
DtEnd = DATEADD("m", 6, WKEnd)

Set objconn = Server.CreateObject("ADODB.Connection")
objconn.ConnectionString = "DRIVER=xxx; SERVER=xxx; PORT=xxx; DATABASE=xxx;     UID=xxx; PASSWORD=xxx; OPTION=xxx"
objconn.Open

Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT DISTINCT `Artist`, `date`, `venue` FROM `WWGigs` WHERE     `Contact`='"&strContact&"' and  DATE >= '"&FormatDate(iDate2, "yyyymmdd", "-    ")&"'"
objRS.Open strSQL, objconn

IF objRS.BOF AND objRS.EOF THEN
ELSE
DO UNTIL objRS.EOF
    stractname2 = objRS("Artist")

    objRS.MoveNext
LOOP
END IF
objRs.Close
Response.write stractname
%>
<table width="1200" border="0" bordercolor="#000000" bgcolor="#000000"     cellspacing="2" cellpadding="0">
<tr><td bgcolor="#000000"><!--#include file="menubar.asp"--></td></tr>
<tr><td bgcolor="#000000"><center><img SRC="<%=strBanner%>" BORDER="0"     WIDTH="1192" HEIGHT="200" /></center></td></tr>
<tr><td align="center"  width="100%">
<table border="1" width="100%" CELLPADDING="3" CELLSPACING="2">
<tr>
    <td ALIGN="CENTER"  COLSPAN="5" BGCOLOR="#FFFFFF"><font face="Calibri"> 
    <b>Acts that have performed at <%=strVenue%> since <%=iDate%><br>
    <img src="return.png" width="13"> Indicates act has future     booking&nbsp;&nbsp;
&nbsp;<img src="favorite.png" width="13"> Indicates act is a favourite&nbsp;    </b></td>
</tr>
<%
DtStart = DATE()-2                                  
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.ConnectionString = "DRIVER=xxx; SERVER=xxx; PORT=xxx; DATABASE=wxxx;     UID=xxx; PASSWORD=xxx; OPTION=xxx"
objconn.Open

iR = 1
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT   DISTINCT `WWGigs`.`Artist` AS `Artist`,     MAX(`WWGigs`.`DATE`) AS `DATEr`,`WWGigs`.`Contact` AS `Contact`,     `Contacts`.`Type` AS `Type`, `Favourites`.`Artist` as `Favourites` FROM (`WWGigs` LEFT JOIN `Favourites` ON `WWGigs`.`Agent`=`Favourites`.`Venue` AND `WWGigs`.`Artist`=`Favourites`.`Artist`) LEFT JOIN `Contacts` ON `Contacts`.`ActName` = `WWGigs`.`Artist` WHERE `WWGigs`.`Artist` <> 'NOT TO BOOK' and `type` <> 'old' AND `WWGigs`.`DATE` >= '"&FormatDate(iDate, "yyyymmdd", "-")&"' and `WWGigs`.`DATE` <= '"&FormatDate(iDate2, "yyyymmdd", "-")&"' AND (`WWGigs`.`Status`='BOOKED' OR `WWGigs`.`Status`='PRIVATE') AND `WWGigs`.`Agent`='"&strVenue&"' group by `Type` DESC ,`Artist` ASC , `date` DESC"
objRS.Open strSQL, objconn
Do While Not objRS.EOF

strArtist = objRS("Artist")
strfav = objRS("Favourites")

if strfav <> "" then
    strfav = "favorite.png"
    strwidth = "13"
else
    strfav = "favoriteoff.png"
    strwidth = "0"
end if

strdate = objRS("dater")
iDate2 = Date()

IF strdate > iDate2 then
    fontcol = "#ffffff"
    strfav2 = "return.png"
    clip = strArtist
else
    fontcol = "#808080"
    strfav2 = "favoriteoff.png"
    clip2 = strArtist
end if

strType = objRS("Type")
IF (Not Is_Not_Null(strType)) THEN
    strType = "Other Artists"
END IF
IF strTypeCheck <> strType THEN
    IF iR > 1 AND iR <= 5 THEN
        iRow = 5 - iR
        FOR z = 0 TO iRow
            Response.Write "<td>&nbsp;</td>"
        NEXT
        Response.Write "</tr>"
    END IF
    strTypeCheck = strType
    Response.Write "<tr><td colspan=""5"" align=""center""      BGCOLOR=""#999999""><font face=""calibri""><b>"&strType&"</td></tr>"
    iR = 1
END IF
IF iR = 1 THEN
%>
<tr>
<%
END IF
%>
<td ALIGN="CENTER">
        <table border="0" WIDTH="100%">
            <tr>
                <td> <font face="Calibri" size="2" color="<%=fontcol%>">     <%=UCASE(strArtist)%> - <%=UCASE(strDATE)%><i>&nbsp; <img src="<%=(strfav)%>"     width="<%=(strwidth)%>"></i></font></td>
            </tr>
        </table>
    </td>
<%
IF iR = 5 THEN
    iR = 0
%>
</tr>
<%
END IF
iR = iR + 1
objRS.MoveNext
Loop
IF iR > 1 AND iR <= 5 THEN
iR = 5 - iR
FOR z = 0 TO iR
    Response.Write "<td>&nbsp;</td>"
NEXT
Response.Write "</tr>"
END IF
objRs.Close
objconn.Close

%>

1 个答案:

答案 0 :(得分:0)

看看你的问题,大声朗读,然后重新编写。&#34;我不需要展示......&#34;