Auto Calculate Age on all Records
Posted: Fri Oct 29, 2010 4:02 am
Hello...
I need to update once per month all the ages of a DB with 1000 records.
The DB as the Birthday and I did this code (incomplete)
I'm with this a few days and can't get it to work. Tried many things but with no success.
Thanks!
I need to update once per month all the ages of a DB with 1000 records.
The DB as the Birthday and I did this code (incomplete)
Code: Select all
include("ConnectDBParadiso.php");
mysql_select_db("$ConnectDBParadiso") or die ("Erro ao ligar à Base de Dados da Sonika-Event");
$select = "SELECT * FROM tabClientes";
$result = mysql_query($select);
$size = mysql_num_rows($result);
echo $size;
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
$varIdade = "28";
$update = "UPDATE tabClientes SET Idade = '$varIdade' WHERE $i = $i";
mysql_query($update);
$i+=1;
}
date_default_timezone_set('Europe/London');
function functCalculateAge($birthday){
return floor((time() - strtotime($birthday))/31556926);
}I'm with this a few days and can't get it to work. Tried many things but with no success.
Thanks!