Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
steve_lemaster
Worker
Worker



Joined: Dec 26, 2006
Posts: 178

PostPosted: Thu Jul 12, 2007 11:38 am Reply with quote

Is it possible to place a hit counter inside a specific block to count hits within it?

I have a YouTube video embedded in a block that I would like to track the amount of times it has been viewed.
 
View user's profile Send private message Send e-mail
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Thu Jul 12, 2007 12:06 pm Reply with quote

If you want the counter to be "persistent" and cumulative, I think you'd need to store it in a MYSQL table. I don't know if there is an existing table for you to use, probably best to define your own with an integer field, read the value in it, increment it by one and store it each time the video is accessed.

But yes that logic could be contained in a block.
 
View user's profile Send private message Visit poster's website
steve_lemaster







PostPosted: Thu Jul 12, 2007 1:36 pm Reply with quote

I figured as much. I am a bit skittish on goofing with my database and was hoping I could place the code within the block.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Thu Jul 12, 2007 6:15 pm Reply with quote

steve_lemaster, PHP is not "persistent", so you have to figure out other ways to cache the data. A database or a file are really your only options and my vote would be for database as it is ready made to do exactly this (plus it handles all the record locking for you).

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
fkelly







PostPosted: Thu Jul 12, 2007 7:01 pm Reply with quote

For what it's worth: if you use a separate (new) database table for this and embed the logic in a new block, the chances of doing damage are minimal. You can even use NSNgroups + the admin screens to make the block only visible to a group that includes only you. I'd also recommend having a PHPmyadmin window open as you develop it so you can see exactly what happens to the tables. And there's my mysql.php hack (search for it) that allows you to capture any database errors.

Of course having a localhost test system to start with is the ne plus ultra.
 
steve_lemaster







PostPosted: Thu Jul 12, 2007 9:57 pm Reply with quote

fkelly wrote:
For what it's worth: if you use a separate (new) database table for this and embed the logic in a new block, the chances of doing damage are minimal. You can even use NSNgroups + the admin screens to make the block only visible to a group that includes only you. I'd also recommend having a PHPmyadmin window open as you develop it so you can see exactly what happens to the tables. And there's my mysql.php hack (search for it) that allows you to capture any database errors.

Of course having a localhost test system to start with is the ne plus ultra.


Ah! I never thought of that. This seems to be the logical approach.

Just to make sure I am understanding you correctly, you are saying create a separate database for the block in which I am going to place the hit counter in.

Now if I only understood how to write code for MySQL Laughing
 
montego







PostPosted: Fri Jul 13, 2007 5:41 am Reply with quote

steve_lemaster, no, just another table within your existing database. Seriously, just use phpMyAdmin to "Add Table" and you are off and running.... well, ok, so you still have to code it. Wink
 
fkelly







PostPosted: Fri Jul 13, 2007 6:37 am Reply with quote

Hey! I thought I had a three hour time advantage on you M. but you were here ahead of me anyway. But what M. said Steve.
 
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Fri Jul 13, 2007 8:25 am Reply with quote

You can create a seperate PHP page to track the hits.. and just load the page in a block using an iframe
Of course, this won't track anyone who views it through Youtube's site directly

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
steve_lemaster







PostPosted: Fri Jul 13, 2007 2:17 pm Reply with quote

Anyone have any idea how to code something like this?

The YouTube clip is using the embedding feature and I don't know if that would be relevant.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©