letzter Login eines Users

Sooo schnell bin ich nicht.....

$query = mysql_query("SELECT login FROM sessions WHERE nickname = '$nickname'")or die( mysql_error() );
if( mysql_num_rows( $query ) < 1 ){
$login = time();
$sql2 = "INSERT INTO `sessions` (`nickname`, `login`)";
$sql2 .= "VALUES ('$nickname', '$login');";
query($sql2); }

else {
$query1 = "UPDATE sessions SET login ='$login' WHERE nickname='$nickname'";
$result=mysql_query($query1);
}

hab grade so angefangen.....aber....dann datet er die Tabelle nur ab
 
Also falls es jemanden interessiert !! So würde es funktionieren -->

<?php
$login = time();
$query = mysql_query("SELECT login FROM sessions WHERE nickname = '$nickname'")or die( mysql_error() );
$sql2 = "INSERT INTO `sessions` (`nickname`, `login`, `ip`)";
$sql2 .= "VALUES ('$nickname', '$login', '" . $_SERVER[REMOTE_ADDR] . "');";
query($sql2);
if( mysql_num_rows( $query ) >= 6 ){
$query1 = "DELETE FROM sessions WHERE nickname = '$nickname' ORDER BY login ASC LIMIT ".(mysql_num_rows($query)-5);
$result=mysql_query($query1) or die (mysql_error());

}
?>
 
Zurück