How can I show that a new item has been added?
Hi Mr,
I would like to know how to show an image, if a new item, has been added to the database on my site.
This image called new, would appear for one day in my list.
How would I do that?
Thank you for your collaboration.
Best Regards,
Simon Baillargeon
Simon Baillargeon
Peter J. Boettcher posted this at 01:32 — 19th March 2000.
They have: 812 posts
Joined: Feb 2000
Simon,
You're a little vague with the details so I can't be to specific. Probably the best way to do it would be to add a "DATE" column to the table you want listed, and enter the date you added the new record in this new field.
Then when the page gets called you would do some server-side code like this (ASP/VBScript):
Dim CurrentDate 'Get todays date
Dim TableDate 'Date from table
Dim DateDifference 'Difference between date
CurrentDate = Date
'Here is where you would open your DB connection
SQL = "SELECT (your fields would go here, including the new date field we just added) FROM YourTable"
Set DateCheck = Conn.Execute(SQL)
TableDate = DateCheck("DateFromTable")
DateDifference = DateDiff("h",CurrentDate,TableDate)
If DateDifference < 24 Then
DisplayImage = True
Else
DisplayImage = False
End If
Then wherever you're displaying the items just do a check for DisplayItem:
If DisplayItem = True Then
<img src=newitem.gif>
End If
So using this code, any item that is less than 24 hours old would be displayed.
If you're doing a loop through records then this statement would have to go inside that loop.
Regards,
Peter J. Boettcher
PJ | Are we there yet?
pjboettcher.com
roBofh posted this at 02:32 — 19th March 2000.
They have: 122 posts
Joined: Jun 2000
Or if you use cookies, you could set one when the person visits that records current date and time. With a date and time field in your database, you can compare the dates and times of the entries to the date and time of the entry to the date and time of the cookie. AFAIK, that's what UBB does for the light images on the side. There should be samples of code around in various languages to do what you want, especially in Perl.
Rob Radez
OSInvestor.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.