Page 1 of 1

Change Age automatically

Posted: Sat Oct 31, 2009 4:55 am
by hamedx
hi guys . im new to php , is it possible to change age value in mysql automatically when year changes ?

Re: Change Age automatically

Posted: Sat Oct 31, 2009 5:11 am
by it2051229
i think no with mysql alone.. you have to create a program for that in php...

Re: Change Age automatically

Posted: Sat Oct 31, 2009 5:25 am
by hamedx
thanks for reply my friend ,googling not work for me .. can you tell me how to do that ?

Re: Change Age automatically

Posted: Sat Oct 31, 2009 7:17 am
by anand
you can do a while loop. :)

quick code

Code: Select all

$rows = mysql_query("SELECT * FROM user";) or die(mysql_error());
 
while ($x = mysql_fetch_array($rows)) {
 
mysql_query("UPDATE user SET age = age+'1'";)
 
}