View Full Version : Intranet Task.
KidKoala
04-15-2003, 05:37 PM
Hi,
I work for a reasonably large solictor's firm, and they want a feature on their intranet page so that when a user opens the intranet page a popup window appears listing updates to the site, like a "Whats New" window. There is to be a database of information on whats new, and the user must be cookied so that the window only pop's up when new information has been entered into the database.
For example If I have never visited the intranet before and there are 3 entries in the database I want a window with 3 paragraphs to pop up
If I don't look at the intranet for a long time and there are now 5 entries I want a popup window with 2 entries to be displayed.
I'm using IIS on Windows 2000 server, using ASP with an MDB.
Any help would be /much/ appreciated.
KidKoala
Mhtml
04-15-2003, 05:58 PM
So we meet again eh? lol :)
So exactly what are you after? The complete code?
<table width="100%" cellspacing='0" cellpadding="0">
<tr>
<td align="center" valign="middle" colspan="2" bgcolor="2266ac"><b><font color="ffffff">Updates since last visit</font></b></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="e5e5e5">Update Date</td>
<td align="center" valign="middle" bgcolor="e5e5e5">Update info</td>
</tr>
<%
'---------------------------------------------------------------
'' INTRANET UPDATES WRITTEN BY M5 INTERACTIVE
'' VISIT US AT : HTTP://WWW.M5INTERACTIVE.COM
'---------------------------------------------------------------
conn = server.createobject("adodb.connection")
rs = server.createobject("adodb.recordset")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("yourdb.mdb")&";"
sqlGetUpdates = "SELECT * FROM UpdatesTable ORDER BY UpdateDate DESC"
rs.Open sqlGetUpdate, conn
If not rs.eof then
do while not rs.eof
if datediff("n",rs("UpdateDate"),request.cookies("lastHere")) > 1 then
response.write("<tr><td>"&rs("UpdateDate")&"</td><td>"&rs("UpdateInfo")&"</td></tr>")
end if
rs.movenext
loop
end if
rs.close
conn.close
set rs = nothing
set conn = nothing
response.cookies("lastHere") = date()
%>
</table>
Now on the pages that you require it to popup on just have...
<%
conn = server.createobject("adodb.connection")
rs = server.createobject("adodb.recordset")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("yourdb.mdb")&";"
sqlCheckUpdates = "SELECT * FROM UpdateTable ORDER BY UpdateDate DESC"
rs.Open sqlCheckUpdates, conn
If not rs.eof then
if datediff("n",rs("UpdateDate"), request.cookies("lastHere")) > 0 then
response.write("<script>window.open('updates.asp')</script>")
end if
end if
%>
Phew.. what a rush haven't coded ASP since I switched to PHP a few weeks back so it will no doubt need a little bit of tweaking and tuning.... and it's also 2:00am so bleh...lol COFFEE! :)
krycek
04-15-2003, 06:11 PM
heheh, good one Michael - and pretty quick, too! :)
::] krycek [::
Mhtml
04-15-2003, 06:13 PM
Yeah I'm part of the codingforums.com rapid response team. !
KidKoala
04-16-2003, 11:56 AM
OK this is looking brilliant Mhtml, and I would firstly like to thankyou for a rather quick response :).
I have never considered myself a coder, and it's not something I could ever enjoy (I do not think mathmatically etc). Anyway, I have sometimes had to resort to some VERY lame and basic PHP/Jscript programming.
I have, however, not ever touched on ASP, so I know nothing about the language. It would be extrememly helpful to me if someone with a bit of spare time on these boards could just briefly tell me what the variables are in the script (i.e. what I need to change to get it to work with my setup here etc).
Also, Where would the first section of code go?
Cheers again
KidKoala
Mhtml
04-16-2003, 12:25 PM
Ok, we will start from the ground up here!
Now, first you are going to need your database!
Can you create one or would you like me to do it?
Your database should have the table called Updates containing these fields:
Update - Memo
UpdateDate - Date/Time
[edit:] Or if you'd like I can create all the required files and a manual for you.
david7777
04-16-2003, 12:29 PM
Maybe you should go have a look at http://www.w3schools.com/asp/default.asp
It's a great site with good tutorials and explains everything about the technology from how to use it, to database connections (ADO) and language syntax.
david7777
04-16-2003, 12:31 PM
Sorry - posts crossed :D
KidKoala
04-16-2003, 02:15 PM
Originally posted by Mhtml
Ok, we will start from the ground up here!
Now, first you are going to need your database!
Can you create one or would you like me to do it?
Your database should have the table called Updates containing these fields:
Update - Memo
UpdateDate - Date/Time
[edit:] Or if you'd like I can create all the required files and a manual for you.
I've already got a database in a "database" dir from the root of the site, tis called stonekingmdb.mdb, I will create the table now, do i need an autonumber colum?
KidKoala
(BTW i'm in the London office at the moment which is 100 odd miles away from my desk so I'm dialing in to work to do it all lol its painful!
Mhtml
04-16-2003, 02:22 PM
lol, sounds like it!
Yes! An autonumber column will be needed!
TABLE: Updates
Fields:
UpdateId - Autonumber
Update - Memo
UpdateDate - Date/Time
What information exactly do you want to be displayed to the user?
Something like:
Date | Update
----------------------
1/1/02 | New stuff
In table form of course!
david7777
04-16-2003, 02:23 PM
An autonumber colum is always a good idea to prevent duplication of records, thus causing problems when trying to edit/remove/view a certain record.
Mhtml
04-16-2003, 02:26 PM
Exactly!
KidKoala
04-16-2003, 03:08 PM
Originally posted by david7777
An autonumber colum is always a good idea to prevent duplication of records, thus causing problems when trying to edit/remove/view a certain record.
Attached is my table :)
Yes, that layout is pretty much exactly what I need :).
Where in the script does it set the cookie?
KidKoala
Mhtml
04-16-2003, 03:12 PM
Ok, I've discovered that you will need to rename the field Update to UpdateText, because Update is a reserved word in SQL lol .. oops ;).
Disregard the scripts I have written up the top, they aren't very good and have errors all over the place.. If you give me a few seconds I'll show you the new and improved version!
Mhtml
04-16-2003, 03:27 PM
Okay, this is what I've made so far http://mhtml.ithium.net/Updates.exe ...
It's working but It's not really something to look at, I'm hoping you know Html and CSS to make it look appealing.
You will have to configure the application by changing the location of the database to the correct location..
You can do that by opening "Updates_Config.asp" in notepad, there is only 1 or 2 lines in the code so you can easily see it.
If you'd like me to tidy it up and make it look like something presentable just give me a color scheme and a logo (not required) and I'll whip something..
Also I haven't created the manual for it yet although there isn't much to know apart from use the Update_AddNew.asp page to add new updates and make sure you fill in the form. But I can still do that some other time if you wish but since I'm not getting payed I'm going to sleep now. . . well soon anyway.
Oh and one more thing, some sort of a link or slipping "M5 interative" into a conversation would be good lol ;).
KidKoala
04-17-2003, 10:19 AM
OK there is a problem, I was mistaken. The files for our intranet are on c:\inetpub\skintranet, and the database is in c:\Inetpub\intranetdatabase. It appears the site was originally coded in macromedia dreamweaver. There is a file called Connections/stoneking.asp, with the following code in it:
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
MM_stoneking_STRING = "dsn=stonekingdsn;"
%>
Then this is a sample file where it connects to the database.
What should I do to modify your scripts to work in this way?
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/stoneking.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_stoneking_STRING
Recordset1.Source = "SELECT * FROM tblUnitPhoneList ORDER BY fldSurname ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
KidK
KidKoala
04-17-2003, 03:31 PM
Cmon guys!! I'm desperate!!!
Kid Koala
Mhtml
04-17-2003, 06:39 PM
the file Updates_Config.asp has the variable which holds the value of the location of the database.
All you need to do is change it to where the file is located. Simple. I hope it is anyway.
KidKoala
04-17-2003, 09:12 PM
Dude read it again, we are using DSN so it's not that simple :(
KidKoala
Roy Sinclair
04-17-2003, 10:28 PM
With only a string defining the DSN, you need to create a connection object like this:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/stoneking.asp" -->
<%
set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open MM_stoneking_STRING
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = oConn
Recordset1.Source = "SELECT * FROM tblUnitPhoneList ORDER BY fldSurname ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
Mhtml
04-19-2003, 03:53 AM
Ok, well if you can hold off untill about 5:00PM Today (19/4/03) I can implement the DSN connection into the script.. I knew I should have thrown a included connection in to it.. I'll have to do that.
Sorry I can't do it right now, but I'm busy preparing for my sister's 21st and my mother is a slave driver .. ;)
KidKoala
04-22-2003, 10:06 AM
aww thanks dude, have i given you enough information on it? how was the sister's bday?
KidKoala
KidKoala
04-23-2003, 10:58 AM
Have you managed to look into this yet MHTML?
Thanks
KidKoala
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.