Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

cara membuat penghitung waktu mundur untuk situs web penawaran

ubah setTimeout dengan ini:

setTimeout(function(){countdown(theyear,themonth,theday,id);},1000)

anda dapat membuat fungsi Anda ke fungsi jQuery seperti itu:

jQuery.fn.countdown = function(yr,m,d){
   $that = $(this);
   theyear=yr;themonth=m;theday=d
   var today=new Date()
   var todayy=today.getYear()
   if (todayy < 1000)
      todayy+=1900
   var todaym=today.getMonth()
   var todayd=today.getDate()
   var todayh=today.getHours()
   var todaymin=today.getMinutes()
   var todaysec=today.getSeconds()
   var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
   futurestring=montharray[m-1]+" "+d+", "+yr
   dd=Date.parse(futurestring)-Date.parse(todaystring)
   dday=Math.floor(dd/(60*60*1000*24)*1)
   dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
   dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
   dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
   if(dday==0 && dhour==0 && dmin==0 && dsec==0){
      $that.val(current);
      return
   }
   else
     $that.val("Only "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds   left "+before);
 setTimeout(function(){ $that.countdown(theyear,themonth,theday);},1000)
}

<?php 
include('../connection.php');
    $rs = mysql_query("select * from datepic") or die(mysql_error());

    if(mysql_num_rows($rs)){

        while($row = mysql_fetch_array($rs))
        {
            $date = str_replace('-',',',$row['date']);

            echo '<input type="text" id="'.$row['id'].'" size=80>';
            ?>
            <script>
                $("?php echo $row['id'] ?>").countdown(<?php echo $date?>);

            </script>


            <?php           

        }
    }

?>



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MYSQL hapus semua hasil yang memiliki count(*)=1

  2. Menukar nilai kolom di MySQL

  3. MySQL:daftar jumlah untuk beberapa kondisi dalam satu pernyataan SQL

  4. Masalah dalam menghubungkan ke server mysql:ERROR 2003 (HY000)

  5. Mencoba memahami mengapa Anda menggunakan jenis pengaturan basis data ini