master82 Posted September 4, 2006 Share Posted September 4, 2006 Here is what i currently have to update my users days old - it will be part of a cron that is run at midnight.[code]include_once("connectionfile.php");mysql_query("UPDATE users SET daysold=daysold+1",$connect);[/code]Now if I was to run this would it go through each row in the users table and add 1 to the field named 'daysold' or will it do the thing I really dont want and make everyones 'daysold' the same.If the second, can anyone add to my code to make the calculation for each row? Link to comment https://forums.phpfreaks.com/topic/19692-field-updates/ Share on other sites More sharing options...
wildteen88 Posted September 4, 2006 Share Posted September 4, 2006 I think it'll go through each user in the database and update the daysold field. Link to comment https://forums.phpfreaks.com/topic/19692-field-updates/#findComment-85892 Share on other sites More sharing options...
master82 Posted September 4, 2006 Author Share Posted September 4, 2006 Thats what I thought might happen.Any idea how I would do it for each row in the users table? Link to comment https://forums.phpfreaks.com/topic/19692-field-updates/#findComment-85893 Share on other sites More sharing options...
master82 Posted September 4, 2006 Author Share Posted September 4, 2006 [code]$query = mysql_query( "select * from users" );while( $row = mysql_fetch_array( $query ) ){mysql_query( "update users set daysold = daysold+1 where id = '$row[id]'" );}[/code]Would this work? Link to comment https://forums.phpfreaks.com/topic/19692-field-updates/#findComment-85896 Share on other sites More sharing options...
master82 Posted September 4, 2006 Author Share Posted September 4, 2006 oh think i misread that 1 lol Link to comment https://forums.phpfreaks.com/topic/19692-field-updates/#findComment-85899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.