Here is a beautiful graphic counter designed without CGI.
This is divided into three parts: 1. Create graphics files.
2. Create a database.
3. Write code.
1. Create graphics files.
First, use graphing software to create 10 graphics to display the ten numbers of the counter: 1, 2, 3, 4, 5, 6, 7, 8, 9, 0. If you have artistic talent, you can make better graphics.
2. Create a database.
Use to create a database named. The database contains a table,
The name is, the structure is: integer, there is one record, and the initial value is 0.
Used to store the last number of visits to this page.
3. Write code.
——————number.asp————————————
<%@ language="vbscript" %>
<!--#include file="adovbs.inc"-->
<%
set objconn=server.createobject("adodb.connection")
objconn.attributes=adxactcommitretaining
dbpath=server.mappath("num.mdb")
objconn.open "driver={microsoft access driver (*.mdb)};dbq=" & dbpath
Note: Establish a connection with the database.
sqlquery= "select * from numt"
set rsrecordset=server.createobject("adodb.recordset")
rsrecordset.open sqlquery,objconn,adopenkeyset,adlockoptimistic
Note: Open the database.
application.lock
application("nmb")=rsrecordset("number")
application.unlock
Note: Assign the last access count to the Application object
application.lock
application("nmb")=application("nmb")+1
application.unlock
rsrecordset("number")=rsrecordset("number")+1
rsrecordset.update
rsrecordset.close
objconn.close
set rsrecordset=nothing
set objconn=nothing
Note: Close the database and release the object
dim nmb1
dim str()
nmb1=application("nmb")
redim str(nmb1)
for i=1 to len(nmb1)
str(i)=mid(nmb1,i,1)
Note: For each number, get the corresponding graphic file
select case str(i)
case"0"
imgF="0.gif"
case"1"
imgF="1.gif"
case"2"
imgF="2.gif"
case"3"
imgF="3.gif"
case"4"
imgF="4.gif"
case"5"
imgF="5.gif"
case"6"
imgF="6.gif"
case"7"
imgF="7.gif"
case"8"
imgF="8.gif"
case"9"
imgF="9.gif"
end select
Note: Output graphic
response.write"<img src="&imgF&">"
next
%>