[SOLVED] hits counts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

hits counts

Post by phpcoder »

hi guys,
I have a some prob . i have a page on my LAN that displays link of different movies when user click on any of link the movie starts downloading wat i want is to count the # of hits of movie i have my sql data base dat will update on hits plz help me how i will update my hits count table when user click on the movie links . I knw the form tag but i dont need submit button i want to update table on link click
plz help
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Have the links point to a page where you count the clicks and then redirect to the download.

page with link -> link counter page -> download file
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

Post by phpcoder »

kettle_drum wrote:Have the links point to a page where you count the clicks and then redirect to the download.

page with link -> link counter page -> download file
can u give show me code if u can the link i have is
<a href ="smcserver/movies/matrix.dat">download</a>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Change the links to <a href="download.php?file=matrix.dat">Download</a>

download.php

Code: Select all

//connect to database
   mysql_query("UPDATE downloads SET hits = hits+1 WHERE file = '".$_GET['file']."'"):
   header("Redirect: blah/blah/movies/".$_GET['file']);
   echo "If your download does not start then please click <a href="blah/blah/movies/".$_GET['file']."">here</a>";
Something like that.
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

Post by phpcoder »

kettle_drum wrote:Change the links to <a href="download.php?file=matrix.dat">Download</a>

download.php

Code: Select all

//connect to database
   mysql_query("UPDATE downloads SET hits = hits+1 WHERE file = '".$_GET['file']."'"):
   header("Redirect: blah/blah/movies/".$_GET['file']);
   echo "If your download does not start then please click <a href="blah/blah/movies/".$_GET['file']."">here</a>";
Something like that.
Thanks so much my friend . Soved my prob Thanks so much
Post Reply