Jump to content
xisto Community
Sign in to follow this  
darul0r

How To Program A Counter? counter for clicks on picture

Recommended Posts

hi @ all!i have a website with many partypics.. and now i want to have a counter! if anybody clicks on a pic, the counter which is placed under everypic should notice this! so for every pic i want a counter, which shows how often it was clicked and shown! with which scrpting language should i make it?which is the best for this quest?thx for help!greetz darul0r

Share this post


Link to post
Share on other sites

Did you take a look at the counters on this webpage. There should be one there that you can use to count pagehits, so if you treat each picture as a page then the count will be accurate.
Hotscripts.com

I have not tried any of the scripts live uet but I have a couple that I'm testing.

Nils

Share this post


Link to post
Share on other sites

if all else fails, i suggest going here: https://tools.digitalpoint.com/counter

it's a simple counter and doesn't require signing up or anthing. I've tried it for a day and it seemed to work fine. I ended up using my php counter instead, but this one seems to be decent ^_^

Share this post


Link to post
Share on other sites

with which scrpting language should i make it?

which is the best for this quest?

<{POST_SNAPBACK}>


Apparently you wish to make the counter yourself and not use a ready made one. That's the right attitude. :)

 

PHP is a good choice for language. You should make a page that is used for viewing a picture. Use a parameter at the end of the URL to identify which image is loaded. So the url to view a picture would be like: yoursite.com/viewpic.php?pic=1

 

The variable "pic" here can be accessed with $_GET['pic']

 

Then of course you need to create some kind of system to save the picture data. You could use simple the picture's name in the variable (yoursite.com/viewpic.php?pic=me.jpg) but that would mean that by changing the url you could view any picture inside yoursite. To avoid you could keep list of pictures that are allowed to be viewed there and check it everytime the page is accessed.

 

Other, and more sophisticated method would be to build a table, a database one if you are familiar with them (if not, it might be worth learning), where you save a unique id (an integer) for each picture. This same table could be used to save the number of time the page is accessed ie. the thumbnail is clicked.

 

For the actual counting, it's easy as pie. Just load the old value of clicks plus one to it and save/update database.

Share this post


Link to post
Share on other sites

counters

 

1.CGI scripts

 

http://forums.xisto.com/no_longer_exists/

 

2. PHP

 

http://forums.xisto.com/no_longer_exists/

 

you can find many interesting stuffs there.

Download the source and may modify them if you know how.

 

there are so many kinds of programs which can display the count invisibly

or by using text(Text based) or images(Graphical).

Share this post


Link to post
Share on other sites

You should use php with mysql. Make a table with a field for the image filename, and a number of clicks, then put something like this on the page that the image takes you to.

<?php$connection = mysql_connect("host","username","password");mysql_select_db("database");$select = "select clicks from table where imagename = 'Image filename';";$sresult = mysql_query($select);$sarray = mysql_fetch_array($sresult);$clicks = $sarray+1;$query = "update table set clicks = '".$clicks."' where imagename = 'Image filename';";mysql_query($query);mysql_close($connection);?>
That's assuming you know the basics of PHP and MySQL. If not, I can tell you in full.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.