Hej alle jer der ude.
Jeg arbejder med at køre en countdown i en php fetch_array hvor jeg henter datoen den skal tælle ned fra i min mysql.
Jeg kan godt få den til at virke hvis jeg kun printer den 1 gang! men så snart jeg vil køre den på en side hvor den skal skrive fx 2 nedtæller ud fejler den, har bikset med det i rigtigt lang tid, og håber i kan fortælle mig hvad det er der går galt.
jeg vil vise jer koden her.
- $alleaktioner = mysqli_query($conn, "SELECT * FROM aktioner ") or die(mysqli_error($conn));
-
-
- while($row = mysqli_fetch_array($alleaktioner))
-
-
-
- {
-
-
-
- echo "<table id=\"alleaktioner\">";
- echo "<tr>";
- echo "<td class=\"produktbilled\">";
- echo "<img width=\"175\" src=\"produktbilleder/". $row['billedid']. ".png\" />";
- echo "</td>";
- echo "<td class=\"produktinfo\">";
- echo "<center><h2 style=\"font-size:30px;\">". $row['produktnavn']. "</h2></center>";
- echo "<div id=\"produktbeskrivelse\">". $row['produktbeskrivelse']. "</div>";
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td class=\"nedtæller\">";
- echo "<center>" . date("d", $countdowndate);
-
-
-
- ?>
- <table id="nedtæller" >
- <tr>
- <div class="numbers" id="count2"></div>
- </tr>
- <tr>
- <td id="brede"><div id="dday"></div></td>
- <td id="brede"><div id="dhour"></div></td>
- <td id="brede"><div id="dmin"></div></td>
- <td id="brede"> <div id="dsec"></div></td>
- </tr>
- <tr >
- <td id="brede" ><div id="days">Dage</div></td>
- <td id="brede"> <div id="hours">Timer</div></td>
- <td id="brede"><div id="minutes">Minutter</div></td>
- <td id="brede"> <div id="seconds">Sekunder</div></td>
- </tr>
- </table>
-
- <?php
- echo "</center>";
- echo "</td>";
- echo "<td class=\"spilnu\">";
- echo "<center><a href=\"aktioner.php?id=". $row['id']. "\" class=\"btn btn-link-1\" >gå videre</a></center>";
- echo "</td>";
- echo "</tr>";
- echo "</table>";
-
-
- }
og her er det tilhørende java script :
- <script type="text/javascript">
-
- /* Change the items below to create your countdown target date and announcement once the target date and time are reached. */
-
- var current="Aktionen er slut"; //—>enter what you want the script to display when the target date and time are reached, limit to 20 characters
-
- var year=<?php echo date("Y", $countdowndate); ?>; //—>Enter the count down target date YEAR
-
- var month=<?php echo date("m", $countdowndate); ?>; //—>Enter the count down target date MONTH
-
- var day=<?php echo date("d", $countdowndate); ?>; //—>Enter the count down target date DAY
-
- var hour=<?php echo date("H", $countdowndate); ?>; //—>Enter the count down target date HOUR (24 hour clock)
-
- var minute=<?php echo date("i", $countdowndate); ?>; //—>Enter the count down target date MINUTE
-
- var tz=<?php echo date("s", $countdowndate); ?>; //—>Offset for your timezone in hours from UTC (see http://wwp.greenwichmeantime.com/index.htm to find the timezone offset for your location)
-
-
- //—> DO NOT CHANGE THE CODE BELOW! <—
-
- var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
-
-
- function countdown(yr,m,d,hr,min){
-
- theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min;
-
- 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 todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
-
- var todaystring=Date.parse(todaystring1)+(tz*1000*60*60);
-
- var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min);
-
- var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60));
-
- var dd=futurestring-todaystring;
-
- var dday=Math.floor(dd/(60*60*1000*24)*1);
-
- var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
-
- var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
-
- var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
-
- if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
-
- document.getElementById('count2').innerHTML=current;
-
- document.getElementById('count2').style.display="inline";
-
- document.getElementById('count2').style.width="390px";
-
- document.getElementById('dday').style.display="none";
-
- document.getElementById('dhour').style.display="none";
-
- document.getElementById('dmin').style.display="none";
-
- document.getElementById('dsec').style.display="none";
-
- document.getElementById('days').style.display="none";
-
- document.getElementById('hours').style.display="none";
-
- document.getElementById('minutes').style.display="none";
-
- document.getElementById('seconds').style.display="none";
-
- document.getElementById('spacer1').style.display="none";
-
- document.getElementById('spacer2').style.display="none";
-
- return;
-
- }
-
- else {
-
- document.getElementById('count2').style.display="none";
-
- document.getElementById('dday').innerHTML=dday;
-
- document.getElementById('dhour').innerHTML=dhour;
-
- document.getElementById('dmin').innerHTML=dmin;
-
- document.getElementById('dsec').innerHTML=dsec;
-
- setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);
-
- }
-
- }
-
-
- countdown(year,month,day,hour,minute);
-
- </script>
Håber i kan hjælpe mig, hav en dejlig aften.