jamiecottonuk
Technical User
Hi all,
I am trying to display data from a database. I want the page to be displayed as
January
event 1
Febraury
March
event 2
event 3
April
etc etc etc.
So if there is an event in that month then display the event
I thought this would do it the months are displayed but no events are being displayed under the correct months and I dont understand. Could someone help?
I am trying to display data from a database. I want the page to be displayed as
January
event 1
Febraury
March
event 2
event 3
April
etc etc etc.
So if there is an event in that month then display the event
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="connection.asp"-->
<%
Dim searchRecordset,searchSQL
Set searchRecordset = Server.CreateObject("ADODB.Recordset")
searchSQL="SELECT * FROM month, events WHERE month.id = events.monthId"
Set searchRecordset= DBConnection.Execute(searchSQL)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p>
<%
dim i
i = 1
Do while Not i = 13
Response.Write("<table>")
Response.Write("<tr>")
Response.Write("<td>"& MonthName(i) &"</td>")
Response.Write("</tr>")
Response.Write("<tr>")
Do while Not searchRecordset.eof
IF searchRecordset("month") = MonthName(i) THEN
Response.Write("<td>"&searchRecordset("event")&"</td>")
END IF
searchRecordset.MoveNext
LOOP
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td> </td>")
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td> </td>")
Response.Write("</tr>")
Response.Write("</table>")
i=i+1
Loop
searchRecordset.close
Set searchRecordset = nothing
'closing the connection
DBConnection.close
Set DBConnection = nothing
%>
</p>
</body>
</html>
I thought this would do it the months are displayed but no events are being displayed under the correct months and I dont understand. Could someone help?