sql >> Database >  >> RDS >> Mysql

hoe u een afteltimer kunt maken voor de biedwebsite

verander setTimeout hiermee:

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

je kunt je functie naar jQuery zo laten werken:

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. DBMS-zelfstudie:een complete spoedcursus over DBMS

  2. Neo4j - Creëer een relatie met Cypher

  3. Basisprincipes van SQL Server ALTER TABLE-instructie

  4. PostgreSQL Machtigingen van pg_catalog-tabellen intrekken