views:

60

answers:

1

Hi,

First of all Thank You for looking.

whats the best method for make an advance click counter (eg. order by views [today] | [yesterday] [this week] [last week] [this month] [last month] [all time] ).

Is it better to use a flat file or mysql?.

This is the MYSQL Structure i came up with.

id (type: int(11)) link_id (type: int(11)) date (type: date) counter (type: int(11))

please can you advice me on whats the most effective way of doing this.

A: 

SQL used with proper indices. SQL data are essentially stored on disk, what makes them more valuable is the fact indices make finding specific records/data faster.

Your scheme should look something like:

Links(id:int, href:string)
Clicks(link_id:int, time:int, counter:int)
msakr
thanks for your respond and i already have the links table setup just want to add cliks
jay
what am i doing wrong here?mysql_query("INSERT INTO views SET site_id='{$id}', time='{$time}' ON DUPLICATE KEY UPDATE views=views+1") or die('Could not update data: ' . mysql_error());
jay
I've never encountered this syntax before but straight away I could tell that your Update subquery needs more work; eg, include the table name? views seems to be both a table AND a column? Isn't that a little ambiguous?
msakr
thanks for the reply but i dont think you have use "ON DUPLICATE KEY UPDATE" before it was released on mysql 4.1, i think most people don't take the advantage of it
jay