Jump to content

Clear a Field Nightly


SlimSlyk

Recommended Posts

Hello,

I have a database table with a structure like this:
id
title
url
total_clicks
today_clicks

Basically, I want to select all of the rows where today_clicks does not equal 0 (To prevent unnecessary load at 00:00 when a server seems most likely to crash anyways), and have it clear today_clicks for all of those rows. I was thinking that a foreach would be needed, but I don't have my PHP book handy and don't really know how to structure one.

Could someone help me out here please?

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/12653-clear-a-field-nightly/
Share on other sites

I'm not sure if I understand what you're asking, but let me just attempt an answer. If you want this to be done nightly automatically then you'll need to schedule a cron job to run a PHP script. It cannot be done with PHP alone. If you're just interested in going everynight and running the script through your browser then that would work fine. I run a query like:
UPDATE $tablename SET $changingrow = '0' WHERE $someotherrow = '$somecondition'
I hope you can see the intent behind the query, just swap in your values for mine.
Link to comment
https://forums.phpfreaks.com/topic/12653-clear-a-field-nightly/#findComment-48553
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.