SlimSlyk Posted June 22, 2006 Share Posted June 22, 2006 Hello,I have a database table with a structure like this:idtitleurltotal_clickstoday_clicksBasically, 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 More sharing options...
Buyocat Posted June 22, 2006 Share Posted June 22, 2006 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 More sharing options...
SlimSlyk Posted June 22, 2006 Author Share Posted June 22, 2006 I know that I will need to run a cron job to do this.Mostly I guess I am curious to know how I can select rows from the table where today_clicks does _not_ equal 0. From there I should be able to do a where() to update each row. Link to comment https://forums.phpfreaks.com/topic/12653-clear-a-field-nightly/#findComment-48558 Share on other sites More sharing options...
SlimSlyk Posted June 22, 2006 Author Share Posted June 22, 2006 Nevermind, figured it out.Thanks! Link to comment https://forums.phpfreaks.com/topic/12653-clear-a-field-nightly/#findComment-48609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.