master82 Posted July 5, 2006 Share Posted July 5, 2006 I've set up my cron to run my php file every hour, but at the moment that file is blank because I'm unsure how to go about it.In my database I have 3 fields, [[b]Progress[/b]],[[b]maxprogress[/b]] and [[b]work[/b]].I need a script that does the following:update [[b]progress[/b]] by 10% of the [[b]maxprogress[/b]], [i]or 15% increase if [[b]work[/b]] = 1[/i]ensuring that [[b]progress[/b]] does not exceed [[b]maxprogress[/b]]Hope that wasn't too complicated to understand - anyone know how I can go about this? Link to comment https://forums.phpfreaks.com/topic/13784-mass-value-change-for-cron-use/ Share on other sites More sharing options...
mrwhale Posted July 6, 2006 Share Posted July 6, 2006 This should work:[code]<?php$query = mysql_query( "select * from table" );while( $row = mysql_fetch_array( $query ) ){ if( $row[work] == 1 ? $work = 15 : $work = 10 ); $new = ( ( 100 / $row[maxprogress] ) * $work ) + $row[progress]; if( $new > $row[maxprogress] ? $new = $row[maxprogress] : $new = $new ); mysql_query( "update table set progress = '$new' where id = '$row[id]'" );}?>[/code] Link to comment https://forums.phpfreaks.com/topic/13784-mass-value-change-for-cron-use/#findComment-53666 Share on other sites More sharing options...
master82 Posted July 6, 2006 Author Share Posted July 6, 2006 Thank you - I'll give it a try now :-) Link to comment https://forums.phpfreaks.com/topic/13784-mass-value-change-for-cron-use/#findComment-53747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.