Jump to content

Recommended Posts

Hello , I have a database for downloads and a download counter but I want to add the "Popular downlads" for that week , so need to add a timeline somehow so the downloads counter only gets updated within a weeks timescale , instead of all the time , as my older downloads are allways at the top of the download counter

 

This is how I update the counter

mysql_query("UPDATE $table SET downloads=downloads+1 WHERE id='$id'");

 

 

This is my table layout

 

`id` int(5) NOT NULL auto_increment,
  `filename` varchar(200) NOT NULL default '',
  `dispname` varchar(200) NOT NULL default '',
  `member` varchar(50) NOT NULL default '',
  `timestamp` varchar(50) NOT NULL default '',
  `downloads` int( NOT NULL default '0',

 

 

Please help if you can im pulling my hair out ;)

 

What about another table, ie download_log

 

`id` int(5) NOT NULL auto_increment, //uid

`did` int(5) NOT NULL , //download ID

`timedate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

 

then just insert a record on every download this will give you a better idea of stats

but remember to include a clean up,, ie delete all records where the timestamp is older that a week/month/year whatever!

I would prefer to have a new row on the excisting table as I have the downloads row on each of my tables

 

I have about 100 different tables for the different filetypes , but I just want one of the tables to be able to show the "Popular Downlaods" this week

Okay let give an example

if i was going to store details from 3 files types ie jpg,png and gif

 

I could create 3 tables

ie

Table: jpeg_file

Fields: height, width, filename

 

Table: png_file

Fields: height, width, filename

 

Table: gif_file

Fields: height, width, filename

 

But as each hold the same data it would be easier to create 1 table and add a field for each type

ie

Table: image_file

Fields: height, width, filename, filetype

 

filetype would be set to "jpg" or "png" or "gif"

 

Okay let give an example

if i was going to store details from 3 files types ie jpg,png and gif

 

I could create 3 tables

ie

Table: jpeg_file

Fields: height, width, filename

 

Table: png_file

Fields: height, width, filename

 

Table: gif_file

Fields: height, width, filename

 

But as each hold the same data it would be easier to create 1 table and add a field for each type

ie

Table: image_file

Fields: height, width, filename, filetype

 

filetype would be set to "jpg" or "png" or "gif"

 

 

Yes that looks better but I have allready got all my database set up now , I shuld have done it that way to start

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.