setting up a database for tracking which users have clicked which links? setting up a database for tracking which users have clicked which links? sql sql

setting up a database for tracking which users have clicked which links?


You could simply make a PHP script that would retrieve the requested link for them, while also adding a value to MySQL.

If I were going to do this, I'd probably do something like this:

<a href="getResource.php?res=video1.mpg&type=video">Video 1</a>

And in PHP, I'd simply get the resource, type and the userid from the session, put them into the database, then retrieve the resource they were looking for. To track if they watched the video the entire way through, you could use javascript to watch for the event of the player coming to an end, then just use a skin that doesn't have a scrub bar.


you need for example a table "users: id, name, etc..." and a table "clicks: user_id, url".

to track link clicks you could do something like this:

<a hreF="log_click.php?url=<?php echo urlencode("some_url?some=param&etc=anything"); ?>">

log_click.php

<?php$url = $_GET['url'];$user = /* ie. $_SESSION['user_id'] *//* insert to database */header('Location: '. $url); // maybe need urldecode($url) hereexit;?>


Interesting project. You should extract the user from the current accesed page and store in a visited pages log (within the database) for each user.