marksquall
05-30-2006, 12:15 AM
Dear WebDeveloper.com Members,
Hello. Good day to all!
I just want to ask some tips on how could I "extract" data (i.e. date data) from my MSAccess and display someone's name on my page if it is their birthday today.
Initially I have this fields on my MSAccess table named TableEmp:
Name
BMonth
BDay
BYear
Respectively.
When I logged in as an admin on the page, I have the option to add a person on my database, with this following code:
<form name="form" method="post" action="AddNewRecord.asp">
<INPUT type="text" name="wholename">
<SELECT name="BDAY">
<OPTION value=0 selected></OPTION>
<OPTION value=1>1</OPTION>
<OPTION value=2>2</OPTION>
...
<OPTION value=31>31</OPTION>
</SELECT>
<SELECT name="BIRTHMONTH">
<OPTION value=0 selected></OPTION>
<OPTION value=1>January</OPTION>
<OPTION value=2>February</OPTION>
...
<OPTION value=12>December</OPTION>
</SELECT>
<INPUT type="text" maxLength=4 size=4 name="BYEAR">
</form>
In turn, this is the code of my AddNewRecord.asp:
<%
response.Buffer = true
Name=request.form("wholename")
BiMonth=request.form("BIRTHMONTH")
BiDay=request.form("BDAY")
BiYear=request.form("BYEAR")
dim conn, rs
set conn = Server.CreateObject ("ADODB.Connection")
conn.open "Provider = Microsoft.jet.OLEDB.4.0;" & "Data Source = " & _
Server.MapPath ("Database/MyDB.mdb")
set rs = Server.createObject ("ADODB.recordset")
rs.open "INSERT Into TableEmp Name,BMonth,BDay,BYear)
values('" & Name &"','" & BiMonth &"','" & Biday &"','" & "','" & BiYear & "'"
& ")",conn
response.redirect("Main.asp")
%>
So if I logged out, then an "ordinary" employee logged in (with no admin rights) and in case today is his/her birthday, therefore he/she will see his/her name on the left side of the page...greeting in his/her birthday.
I don't know if it is correct to have the date, month, year of the birthday be separated on different data fields on MSAccess, or just in one data field. Because when I click "View Records" when I logged in, I see numbers on birth months and not name of months(I know because I used numbers as values corresponding to months). or should I use another table in MSAccess (let's say tablemonths that has two fields: BMonth and Monthname) that has relationship with BMonth in my TableEmp)
Hope I could be enlighten with this one. I don't know how to make comparisons. I tried some code mentioned here but I didn't work. More power to everyone. Thank you!
Warn regards,
MarkSquall
Hello. Good day to all!
I just want to ask some tips on how could I "extract" data (i.e. date data) from my MSAccess and display someone's name on my page if it is their birthday today.
Initially I have this fields on my MSAccess table named TableEmp:
Name
BMonth
BDay
BYear
Respectively.
When I logged in as an admin on the page, I have the option to add a person on my database, with this following code:
<form name="form" method="post" action="AddNewRecord.asp">
<INPUT type="text" name="wholename">
<SELECT name="BDAY">
<OPTION value=0 selected></OPTION>
<OPTION value=1>1</OPTION>
<OPTION value=2>2</OPTION>
...
<OPTION value=31>31</OPTION>
</SELECT>
<SELECT name="BIRTHMONTH">
<OPTION value=0 selected></OPTION>
<OPTION value=1>January</OPTION>
<OPTION value=2>February</OPTION>
...
<OPTION value=12>December</OPTION>
</SELECT>
<INPUT type="text" maxLength=4 size=4 name="BYEAR">
</form>
In turn, this is the code of my AddNewRecord.asp:
<%
response.Buffer = true
Name=request.form("wholename")
BiMonth=request.form("BIRTHMONTH")
BiDay=request.form("BDAY")
BiYear=request.form("BYEAR")
dim conn, rs
set conn = Server.CreateObject ("ADODB.Connection")
conn.open "Provider = Microsoft.jet.OLEDB.4.0;" & "Data Source = " & _
Server.MapPath ("Database/MyDB.mdb")
set rs = Server.createObject ("ADODB.recordset")
rs.open "INSERT Into TableEmp Name,BMonth,BDay,BYear)
values('" & Name &"','" & BiMonth &"','" & Biday &"','" & "','" & BiYear & "'"
& ")",conn
response.redirect("Main.asp")
%>
So if I logged out, then an "ordinary" employee logged in (with no admin rights) and in case today is his/her birthday, therefore he/she will see his/her name on the left side of the page...greeting in his/her birthday.
I don't know if it is correct to have the date, month, year of the birthday be separated on different data fields on MSAccess, or just in one data field. Because when I click "View Records" when I logged in, I see numbers on birth months and not name of months(I know because I used numbers as values corresponding to months). or should I use another table in MSAccess (let's say tablemonths that has two fields: BMonth and Monthname) that has relationship with BMonth in my TableEmp)
Hope I could be enlighten with this one. I don't know how to make comparisons. I tried some code mentioned here but I didn't work. More power to everyone. Thank you!
Warn regards,
MarkSquall