Is this possible? (mysql question)
  • 2010/3/27 18:13

  • agf8623

  • Just popping in

  • Posts: 59

  • Since: 2004/5/15

Is there a way to decrease the value in a table by 50% (whole numbers only) at a specific time each week?

I have a table that counts the # of hits that a product receives. Each week, I want this # to decrease by 50% every 7 days.

How would I do this?

Re: Is this possible? (mysql question)
  • 2010/3/27 21:00

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23

Hmmm yes possibly possible (interesting sentence really )

If you record the clicks as update and with a timestamp.

$sql "UPDATE ".$xoopsDB->prefix('table_name')." SET click = click + 1 AND time = NOW() WHERE ID = $id"'";
$result = $xoopsDB->queryF($sql);

Then make a function something like this..

function XX_HalfClicks () {
$sql "UPDATE * FROM ".$xoopsDB->prefix('mytable')." WHERE time = DATE_SUB(NOW(),INTERVAL -1 week) SET click = click/2";

Something like this. The function could forinstance be in the header or something like this (just check the code though, It was simply as an example, I havenet checked if it work or anything :)


Who's Online

133 user(s) are online (22 user(s) are browsing Support Forums)

Members: 0

Guests: 133



Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits