'[b] this all gets killed [/b][COLOR=black red]
'dayarrays = split("Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",",") ' this is for ease of dimming, reordering etc.
'this is now disabled, and built dynamically below
'part of the reasoning for this array will be more appearant later
'for each dayarray in dayarrays
' execute(dayarray & " = Array()") ' dynamically dims the dayarray variable as the variable's content as an array
'next[/color]
' did a conversion so you can have the table rotate as teh days go on if you'd like, otherwise it's static based on the finddate call
'to rotate the days just make founddate = date() and rem the finddate call
' establishing your connection, recordset etc
Dim founddate
founddate=FindDate(1,date(),1) '[COLOR=black cyan][b]my mistake, the day array being static is what caused the problem before(layout) leave this as 1, 1 is sunday in the function, 7 is saturday, 2 is monday[/b][/color]
[b]
'double dutied this loop to dim the arrays, and to make your array set for column headers and array reference
For dateval = FoundDate to FoundDate+6
execute(DayName(DateVal) & " = Array()")' dynamically dims the dayname as an array
dayarrays = dayarrays & DayName(DateVal) & "," ' builds custom dayarray of day names based of your "start Date"
Next
'Strip the last comma off the dayarrays variable
dayarrays = left(dayarrays,len(dayarrays)-1)
'convert dayarrays to an array
dayarrays = split(dayarrays,",")
[/b]
Set rsitem = Server.CreateObject("ADODB.Recordset")
Set ObjConn = Server.CreateObject("ADODB.Connection")
strconnect = "dsn=menu;"
' the strconnect value wasn't in there before, make sure you get it added/corrected
ObjConn.Open strConnect
SQL = "SELECT cafemenu.menudate, cafe.itemname, cafe.description, foodtype.typename FROM (cafemenu INNER JOIN foodtype ON cafemenu.menutypeid = foodtype.typeid) INNER JOIN cafe ON cafemenu.itemselected = cafe.itemnum WHERE (((cafemenu.menudate) Between #" & FoundDate & "# And #" & FoundDate+6 & "#)) ORDER BY cafemenu.menudate, cafemenu.menutypeid, cafemenu.itemselected"
' Please note the addition of #'s to the dates instead of single quotes
' if you're using ACCESS you need #'s
' if you're using SQL you'll need the single quotes
Set rsitem = ObjConn.Execute(Sql)
' these next few sections will be where it might get a little more confusing on you
' what's happening here is the dynamic determination of what weekday a menudate is on
' then adding the RSitem("menuitem") values to the day array, RSitem("menuitem") being an array of recordset items, the dish name, or whatever you're looking to store
' using this way first of all cuts down on hoards of visible code, and lots of conditional statements
' like determining if menudate is on a monday, then if/else add value to array, or proceed to determine if it's a tuesday etc
do while not rsitem.eof
Execute("IF " & dayname(rsitem("menudate")) & "LastType <> """ & rsitem("typename") & """ Then " & dayname(rsitem("menudate")) & " = AddToArray(" & dayname(rsitem("menudate")) & ",""<b>" & RSitem("typename") & "</b>"")")
Execute(dayname(rsitem("menudate")) & " = AddToArray(" & dayname(rsitem("menudate")) & ",""<a href='#' title=""""" & Server.HtmlEncode(rsitem("description")) & """"">" & RSitem("itemname") & "</a>"")")
Execute(dayname(rsitem("menudate")) & "LastType = """ & rsitem("typename") & """")
' Un Rem this next statement to get a better understanding of what's going on :)
' response.write "|" & dayname(rsitem("menudate")) & "LastItem = """ & rsitem("itemname") & """" & "|<br>"
rsitem.movenext
Loop