Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length


News:

Make some extra cash by selling Cronwerks mods with our affiliate system.


AuthorTopic: Delete From Cmarket After a Set Time  (Read 155 times)

Maketextgames.com

  • Active Member
  • **
  • Reputation Power: 112
  • Maketextgames.com is working their way up.Maketextgames.com is working their way up.Maketextgames.com is working their way up.
  • Offline Offline
  • Posts: 204
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Delete From Cmarket After a Set Time
« on: February 13, 2010, 02:43:07 PM »
Another Basic request.

Basically Just deletes Entries and Returns to the user after 7 Days.

Keeps Cmarket from cluttering up :)

First Add this SQL

ALTER TABLE `crystalmarket` ADD `timer` INT(11) NOT NULL DEFAULT 0;

Next Add This to cron_day.php

Code: [Select]
$db->query("UPDATE `crystalmarket` SET `timer`=`timer`+1");

Go to the bottom of cron_day and right above ?>
Add the Following
Code: [Select]
$remove = $db->query("SELECT `cmID`,`cmADDER`,`cmQTY` FROM `crystalmarket` WHERE `timer`>7");
while($take = $db->fetch_row($remove))
{
$db->query("UPDATE `users` SET `crystals`=`crystals`+{$take['cmQTY']} WHERE `userid`={$take['cmADDER']}");
$db->query("DELETE FROM `crystalmarket` WHERE `cmID`={$take['cmID']}");
}


Next you are going to want to open up cmarket.php

Find the query Where it inserts the values into crystalmarket table
Will look something like this.

Code: [Select]
$db->query("INSERT INTO crystalmarket VALUES ('', {$_POST['crystals']}, $userid, {$_POST['price']})");

Change to

Code: [Select]
$db->query("INSERT INTO crystalmarket VALUES ('', {$_POST['crystals']}, $userid, {$_POST['price']}), 0");

Save, Close.

This should be it, any problems post here.

Jordan

  • Active Member
  • **
  • Reputation Power: 55
  • Jordan has no influence.
  • Offline Offline
  • Posts: 103
  • Website Developer for hire;
    • MSN Messenger - Pudda2008@hotmail.co.uk
    • View Profile
    • WWW
    • Email
Re: Delete From Cmarket After a Set Time
« Reply #1 on: February 14, 2010, 07:39:54 AM »
Did this a while back, Good work ^_^ although I wouldn't use the ''idea'' :)
Logged

Pudda2008@hotmail.co.uk - Feel free to add me on MSN