Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][PHP]Javascript countdown i insert do bazy danych
wiktor0000
post 19.04.2020, 14:53:40
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 29.04.2018

Ostrzeżenie: (0%)
-----


Witam, dlaczego gdy zrobie if(minuty i sekundy sa rowne 0) w tym kodzie i dodam insert do bazy php to odrazu dodaje do bazy zanim zaczekać ?
var a = "<?php $cons = mysqli_connect('localhost','root','','bn'); $sql = 'INSERT INTO mecze (imie) VALUES ('123')'; mysqli_query($ ?>";
  1. function startTimer(duration, display) {
  2. var start = Date.now(),
  3. diff,
  4. minutes,
  5. seconds;
  6. function timer() {
  7. // get the number of seconds that have elapsed since
  8. // startTimer() was called
  9. diff = duration - (((Date.now() - start) / 1000) | 0);
  10.  
  11. // does the same job as parseInt truncates the float
  12. minutes = (diff / 60) | 0;
  13. seconds = (diff % 60) | 0;
  14.  
  15. minutes = minutes < 10 ? "0" + minutes : minutes;
  16. seconds = seconds < 10 ? "0" + seconds : seconds;
  17.  
  18. display.textContent = minutes + ":" + seconds;
  19.  
  20. if (diff <= 0) {
  21. // add one second so that the count down starts at the full duration
  22. // example 05:00 not 04:59
  23. start = Date.now() + 1000;
  24. }
  25. };
  26. // we don't want to wait a full second before the timer starts
  27. timer();
  28. setInterval(timer, 1000);
  29. }
  30.  
  31. window.onload = function () {
  32. var fiveMinutes = 10,
  33. display = document.querySelector('#time');
  34. startTimer(fiveMinutes, display);
  35. };


Ten post edytował wiktor0000 19.04.2020, 14:55:57
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.04.2024 - 05:52