Put a page hit counter on your site. This example uses graphics, the File Scripting Object and ASP.
Hit Counter
This example is a simple asp counter using graphics to display the numbers. ASP tutorial about hit counters.
True Type Fonts
Download thousands of free fonts.
Download Here.
Device Drivers
DirectX
VBrun Files
By Peripheral:


All Drivers
Dll Search
Download Dll Files
Enter The Dll Name:
Paco's Screensaver
Download The Official Paco's Drivers Screensaver.
Check It Out
Computer Maintenance
File Systems
Hardware
Over Clocking
Registry
Surf 2X Faster
Desktop Enhancements
Anime
Icons
Screensavers
Themes
Site Search:

Free Software
Anti-Virus
Audio Tools
E-Mail Clients
Firewalls
Graphic Editors
Web Development
ASP/VBScript
CGI Script
HTML
JavaScript
Paco's Own Scripts
Webmasters Tools
Were Listed @

Aspin.com

ScriptSearch.com

Simple Counter With Graphics
This example is a simple counter using graphics to display the numbers. I call it simple because it will only show page views, not actual visitors. It uses the File Scripting Object to interact with a text file. The first thing it does is read the current number in the file and add one to it, then displays it graphically. I am not a real graphics wizard and found these numbers at Scream Design. There are many places to get free graphics but, this is probably the best.  I use Left Right and Mid in this, so if you are not sure about them you will find a detailed example here. I also use Len, explained here. And arrays discussed here. Now lets begin by looking at the example.  

We Have Had
Total Page Views

<%
'here we set up a connection to the txt file using a physical path
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("C:\InetPub\wwwroot\counter\count.txt")

'now we read the number in the file
oldNum = CLng(oFile.ReadLine)

'and we close
oFile.Close

'we add one to the number
oldNum = oldNum + 1

'we open the file to overwrite the new number to it
Set oFile = oFSO.OpenTextFile("C:\InetPub\wwwroot\counter\count.txt",2,true)

'and we overwrite it here
oFile.WriteLine(oldNum)

'and we close the file again
oFile.Close

'now we use the number for our display
strCount = oldNum

'here we are looking at the length of the number (how long it is)
'because this will effect our display table. if it is one digit long like 9
If LEN(strCount) = 1 Then
'we set ali (align) to center
ali = "center"
'if its 2 or more digits long like 35 or 4255 we will align left
'we use this later 
Else
ali = "left"
End If
%>

Below is a mix of html and vbscript. I will display the script in red to make it more discernable.

<div align="center">
<center>
<table border="0" cellspacing="0" cellpadding="0">
<tr>

in this line we are getting the legth of the number again. this tells the table cell how many columns to span
<td colspan="<%=LEN(strCount)%>" align="center">We Have Had</td>
</tr> 
<tr>

Now we only want to show as many cells and numbers as we have data for. So if it is a two or more digit number we will show this cell
<%
If LEN(strCount) > 1 Then
%> 

<td align="Right"><img border="0" src="<%=Left(strCount,1)%>.gif"></td>
<%
End If

'If it is a 3 or more digit  number we will show this cell as well
If LEN(strCount) > 2 Then
Dim numArray
i = (Len(strCount)-1)
For x = 2 to i
ReDim numArray(i)
%>

<td align="center"><img border="0" src="<%=MID(strCount,x,1)%>.gif"></td>
<%
Next
End If
%>

'It will always be at least a one digit number so we allways show this cell. Also note in this line we have used ali from above to set this cell to center or left. Remember we set that up above.
<td align="<%=ali%>"><img border="0" src="<%=Right(strCount,1)%>.gif"></td>
</tr>
<tr>
<td colspan="<%=LEN(strCount)%>" align="center">Total Page Views</td>
</tr> 
</table>
</center>
</div>

What we have done here is break up the number. Lets say it is 123. The first cell in the table has this: <%=Left(strCount,1)%>.gif Essentially, what we did was take the number 1 and use it to reference 1.gif

The second cell has this in it: <%=MID(strCount,x,1)%>.gif. We used that to reference 2.gif

The third cell has: <%=Right(strCount,1)%>.gif. This reference 3.gif.

With this in mind, you want to make sure all your images are named corresponding to the number. So an image with 2 in it would be named 2.gif  Got it?

Don't worry about how many digits long your number is. The array that is built into this script will add as many numbers and cells in the middle as it needs. 

Now create a text file named count.txt and place it in a directory named counter. Add your numbers to the web and you're all set!


Search The Web Using Paco's MetaSearch
  
any   all   phrase
 About  Factmonster  AlltheWeb   
 MSN  Yahooligans      
Arts
Movies, Television, Music...
Business
Jobs, Industries, Investing...
Computers
Internet, Software, Hardware...
Games
Video Games, RPGs, Gambling...
Health
Fitness, Medicine, Alternative...
Home
Family, Consumers, Cooking...
Kids and Teens
Arts, School Time, Teen Life...
News
Media, Newspapers, Weather...
Recreation
Travel, Food, Outdoors, Humor...
Reference
Maps, Education, Libraries...
Regional
US, Canada, UK, Europe...
Science
Biology, Psychology, Physics...
Shopping
Autos, Clothing, Gifts...
Society
People, Religion, Issues...
Sports
Baseball, Soccer, Basketball...
World
Deutsch, Español, Français, Italiano, Japanese, Nederlands, Polska, Svenska...
Help build the largest human-edited directory of the web
Stop Popups
Paco's Popup Plucker.
Eliminate those pesky popups!
Users Online
Currently 62 users at PacosDrivers.com
Paco's Online

Send this page to a friend
Report Broken Links
Bad or missing query parameters in request.
Hosted By
ChamberGates

Privacy Policy
Best Viewed At 1024 X 768 Or Higher
Copyright © 2000-2008 Pacosdrivers.com. All Rights Reserved.