SHARE
TWEET

Untitled

a guest Jun 15th, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $db = "realmd"; // DB kde je Tabulka UPTIME
  3. $ip = "localhost";
  4. $port = "3306";
  5. $user = "root"; // uživatel MySQL
  6. $pass = "password"; // heslo k MySQL
  7.  
  8. // Připojení do DB
  9. $db_spojeni = mysqli_connect
  10. ($ip, $user, $pass, $db, $port);
  11.  
  12. // SQL dotaz
  13. $sql = mysqli_query($db_spojeni, 'SELECT UNIX_TIMESTAMP(NOW())-starttime AS FromLastStart  FROM uptime ORDER BY starttime DESC LIMIT 1');
  14. if(!$sql){
  15.    echo "Špatně napsaný dotaz do databáze";
  16.    exit();
  17. }
  18.  
  19. // Výpis
  20. while ($radek = mysqli_fetch_assoc($sql)){
  21. $cislo = $radek['FromLastStart']*1;
  22. $den = floor($cislo/(24*3600));
  23. $cislo -= $den*24*3600;
  24. $hodin = floor($cislo/3600);
  25. $cislo -= $hodin*3600;
  26. $minut = floor($cislo/60);
  27. $sekund=$cislo-$minut*60;
  28. echo ($den>0?$den.' <b><font color="black">dnu</font></b>, ':'').($hodin*1).' <b><font color="black">hod</font></b>, '.($minut*1).' <b><font color="black">min</font></b>, '.($sekund*1).' <b><font color="black">sec</font></b>';
  29. }
  30.  
  31. // Zavření objektu
  32. mysqli_free_result($sql);
  33.  
  34. // Odpojení od Databáze
  35. if ($db_spojeni)
  36. mysqli_close($db_spojeni);
  37. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top