Hi i have a site with users displayed on the front page. When users sign up to the site they sign up with their date of birth. This is stored in my database.
I have pulled the users from the database and have their location and name displaying.
I am also trying to add their age which is calculated from their date of birth. But at the moment it won’t work, the users age isn’t being displayed.
Can anyone help me find where i’m going wrong?
Code:
<?php
$dob = $platinum['dob'];
function age_from_dob($dob) {
list($y,$m,$d) = explode('-', $dob);
if (($m = (date('m') - $m)) < 0) {
$y++;
} elseif ($m == 0 && date('d') - $d < 0) {
$y++;
}
return date('Y') - $y;
}
$dob = age_from_dob($dob);
?>
<?
$platinum_set = get_platinum_users();
while ($platinum = mysql_fetch_array($platinum_set)) {
echo"
<div class=\"platinumcase\">
<a href=\"profile.php?id={$platinum['id']}\"><img width=80px height= 80px src=\"data/photos/{$platinum['id']}/_default.jpg\" class=\"boxgrid\"/></a><h58> {$platinum['first_name']} {$platinum['last_name']}</h58><br/><br/><h52>{$platinum['$dob']}<br/><br/>{$platinum['location']}</h52>
</div>";
}
?>
1 Answer