<% @Language="VBScript" %> <% Response.CacheControl = "no-cache" %> <% Function fetchActiveRouteCountBySchool(scid) IF scid <> "" AND IsNumeric(scid) THEN '******************************************************************* '******* pass in zero (0) to count all routes from all schools ***** '******************************************************************* IF scid <> "0" THEN 'not zero so filter by school id fbysid=" AND `schoolID`='"&scid&"'" ELSE 'its zero so just count all fbysid="" END IF SET rsBC = dbCBK.Execute("SELECT COUNT(*) AS TBC from cbk_routes WHERE `curSTATUS`='on' "&fbysid&" limit 1") IF rsBC.eof THEN tbc = "0" END IF DO WHILE NOT rsBC.EOF tbc = rsBC("TBC") rsBC.MoveNext loop rsBC.Close SET rsBC = Nothing IF IsNull(tbc) THEN tbc="0" ELSEIF tbc <> "" AND IsNumeric(tbc) THEN tbc=CInt(tbc) IF tbc < 0 THEN tbc="0" END IF END IF fetchActiveRouteCountBySchool=tbc ELSE fetchActiveRouteCountBySchool=0 Exit Function END IF End Function sSch=sanitizeRequest("sSch","querystring") %> <%IF sSch <> "" AND IsNumeric(sSch) THEN%> <%=fetchActiveRouteCountBySchool(sSch)%> <%END IF%>