Hi Leute
Ich konnte das Problem nicht lösen.Aber vielleicht ihr ?
Auf ein Posting von mir vor einigen Tagen hat man mir irgendwie nicht so richtig weitergeholfen.
Vielleicht kann sich ja nochmal jmd erbarmen
Folgender Code sollte mir anzeigen wie alt derjenige ist, dessen Geburtsdatum (z.B. 17.11.1960) in der Tabelle steht.
function ger2enDate($date)
{
$date = explode(".", $date);
$date = $date[2]."-".$date[1]."-".$date[0];
return $date;
}
function getAge($birthday)
{
$today = getdate();
$birthday = explode("-", $birthday);
$birth_day = $birthday[2];
$birth_month = $birthday[1];
$birth_year = $birthday[0];
$today_day = $today["mday"];
$today_month = $today["mon"];
$today_year = $today["year"];
if (substr($birth_day, 0, 1) == "0")
$birth_day = substr($birth_day, 1, 1);
if (substr($birth_month, 0, 1) == "0")
$birth_month = substr($birth_month, 1, 1);
if (substr($birth_year, 0, 1) == "0")
$birth_year = substr($birth_year, 1, 1);
if (substr($today_day, 0, 1) == "0")
$today_day = substr($today_day, 1, 1);
if (substr($today_month, 0, 1) == "0")
$today_month = substr($today_month, 1, 1);
if (substr($today_year, 0, 1) == "0")
$today_year = substr($today_year, 1, 1);
if ($today_month > $birth_month)
$age = $today_year - $birth_year;
if ($today_month == $birth_month) {
$age = $today_year - $birth_year;
if ($today_day < $birth_day)
$age--;
}
if ($today_month < $birth_month)
$age = ($today_year - $birth_year) -1;
return $age;
}
$db_server = "www.jensschmelzer.info";
$db_name = "v035212";
$db_user = "v035212";
$db_passwort = "********************";
$db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort) or die ("Konnte keine Verbindung zur Datenbank herstellen");
$db_check = @MYSQL_SELECT_DB($db_name);
$query = mysql_query("SELECT * FROM benutzer LIMIT 1",$db);
$row = mysql_fetch_row($query);
$alter = getAge(ger2enDate($row[1]));
echo $alter;
mysql_close($db);
?>
Hier könnt ihr das Ergebnis sehen