Langsom kode
HejsaHar lavet noget som udskriver navne fra en mssql database som også virkede fint. da jeg så lavede det sådan at baggrundsfarven skulle være afhængig af en deadline (antal dage fra dd til dato i database) blev siden virkelig langsom...gå selv udfra at det er pga. dårlig kodning..Håber nogen kan hjælpe
Koden:
<tr>
<td colspan=2 align="center">
<%
if request("sorter") = "true" and request("bogstav") <> "alle" and request.QueryString("aktiv") = "" then
sql = "select * from tbl_Clients where client_name LIKE '"&request("bogstav")&"%' Order By client_name"
set rs = conn.execute(sql)
end if
if request("sorter") = "true" and request("bogstav") = "alle" and request.QueryString("aktiv") = "" then
sql = "select * from tbl_Clients Order By BrugerID"
set rs = conn.execute(sql)
end if
if request("sorter") <> "true" and request.QueryString("aktiv") = "" then
sql = "select * from tbl_Clients Order By client_name"
set rs = conn.execute(sql)
end if
if request("aktiv") = "ja" then
sql = "select * from tbl_Clients Where Active = 'True' Order By client_name"
set rs = conn.execute(sql)
end if
if request("aktiv") = "nej" then
sql = "select * from tbl_Clients Where Active = 'False' Order By client_name"
set rs = conn.execute(sql)
end if
if request("sorter") = "" and request("aktiv") = "" then
sql = "Select * From tbl_Clients order by client_name"
set rs = conn.execute(sql)
end if
%>
<% if request.QueryString("aktiv") = "nej" then %>
<table border=0 cellpadding=2 cellspacing=2 width="50%">
<tr>
<td width="70%" valign="top" class="columnheader" bgcolor="<%=gsColorHighlight%>">BORGERE</td>
</tr>
<% do while not rs.eof %>
<tr>
<td valign=top><a href="client-edit.asp?client_id=<%=rs("Client_ID")%>"><%=rs("Client_Name")%></a></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs = nothing
%>
</table>
<% else %>
<table border=0 cellpadding=2 cellspacing=2 width="50%">
<tr>
<td width="70%" valign="top" class="columnheader" bgcolor="<%=gsColorHighlight%>">BORGERE</td>
<td valign="top" class="columnheader" bgcolor="<%=gsColorHighlight%>">DEADLINE</td>
</tr>
<% do while not rs.eof %>
<%
sqlPeriode = "Select * From tbl_AktivPeriode Where Client_ID = " & rs("Client_ID")
set rsPeriode = Conn.Execute(sqlPeriode)
%>
<% if rsPeriode.eof then %>
<tr>
<td valign=top><a href="client-edit.asp?client_id=<%=rs("Client_ID")%>"><%=rs("Client_Name")%></a></td>
<td></td>
</tr>
<% else %>
<% antal_dage = DateDiff("d", Now(), rsPeriode("DatoTil2")) %>
<% if antal_dage > 42 then %>
<tr>
<td valign=top bgcolor="#06ff00"><a href="client-edit.asp?client_id=<%=rs("Client_ID")%>"><b><%=rs("Client_Name")%></b></a></td>
<td bgcolor="#06ff00"><b><%=antal_dage %> dage tilbage</b></td>
</tr>
<% end if %>
<% if antal_dage =< 42 And antal_dage => 21 then %>
<tr>
<td valign=top bgcolor=yellow><a href="client-edit.asp?client_id=<%=rs("Client_ID")%>"><b><%=rs("Client_Name")%></b></a></td>
<td bgcolor=yellow><b><%=antal_dage %> dage tilbage</b></td>
</tr>
<% end if %>
<% if antal_dage < 21 then %>
<tr>
<td valign=top bgcolor=red><a href="client-edit.asp?client_id=<%=rs("Client_ID")%>"><b><%=rs("Client_Name")%></b></a></td>
<td bgcolor=red><b><%=antal_dage %> dage tilbage</b></td>
</tr>
<% end if %>
<% end if %>
<%
rs.movenext
loop
rsPeriode.close
set rsPeriode = nothing
rs.close
set rs = nothing
%>
</table>
<% end if %>
</td>
</tr>