14. april 2004 - 22:18Der er
9 kommentarer og 1 løsning
HJÆLP forhvor virker dette ikke
Hey
nu har jeg siddet med denne kode den sidste time og det virker bare ikke
mysql_query("select lastlogin from bruger where id= $id ") or die (mysql_error()); $time = date("H:i d-m-Y"); function online() { if ($lastlogin == $time) { echo "Online"; }else{ echo "$lastlogin"; } }
nogle der kan sige mig hvorfor den ikke vil sammenligne de to tider
Kommunerne har digitaliseret indgangen for borgerne. Men bag skærmen håndteres mange arbejdsgange stadig manuelt mellem systemer, mails og organisatoriske siloer.
mysql_query("select lastlogin from bruger where id= '$id'") or die (mysql_error()); $time = date("H:i d-m-Y"); function online() { if ($lastlogin == $time) { echo "Online"; }else{ echo "$lastlogin"; } }
$get_login = mysql_query("select lastlogin from bruger where id= $id ") or die (mysql_error()); $login = mysql_fetch_array($get_login); $time = date("H:i d-m-Y"); function online() { if ($login['lastlogin'] == $time) { echo "Online"; }else{ echo "$lastlogin"; } }
$get_login = mysql_query("select lastlogin from bruger where id= $id ") or die (mysql_error()); $login = mysql_fetch_array($get_login); $time = date("H:i d-m-Y"); function online() { if ($login['lastlogin'] == $time) { echo "Online"; }else{ echo $login['lastlogin']; } }
mysql returnere datoer som: 2004-04-14 22:39:17 du laver datoer ($time) som 22:39 14-4-2003
du sammenligner disse som strings og de matcher så ikke.
$res = mysql_query("select lastlogin from bruger where id=$id and date_add(lastlogin, INTERVAL 10 minute) > now()") or die (mysql_error()); $row = mysql_fetch_array($res); if( $row ) print "Online: sidst set " . $row[0]; } else { print "offline"; }
This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope. You may notice that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently change a global variable. In PHP global variables must be declared global inside a function if they are going to be used in that function.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.