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
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
Share on other sites

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.