lasse48 Posted July 30, 2010 Share Posted July 30, 2010 hello guys. i sitting here at my pc , have used alot days on google and forums. but i just cant seem to find what i am looking for so i hope that anyone here got a min to tell me what to do okai soo what i am looking for is a php / mysql script that can countdown for a user , when its finish add a number ( to usertabel[2]. and the problem is it need to do it also if the user closes the browser. i am total lost , have no ide to fix / wihte it Sorry for my spelling i am danish Quote Link to comment Share on other sites More sharing options...
lasse48 Posted July 30, 2010 Author Share Posted July 30, 2010 some thing with adding a time countdown to a mysql tabel and deleting it after use, so when its finish for the user , it will delete the countdown time in the tabel and add a number to the userdata[2] fx. Quote Link to comment Share on other sites More sharing options...
radar Posted July 30, 2010 Share Posted July 30, 2010 you are lucky, i have created something like this just yesterday (literally yesterday).. though you will probably have to alter it a little to fit your specific needs. first off here is my switch (with only the relavent parts left in) default: $date = date('Y-m-d'); $sql = "SELECT * FROM deals WHERE start_date = '".$date."' AND status=1"; $data = mysql_fetch_assoc(mysql_query($sql)); putenv("TZ=US/Mountain"); $page = 'main.tpl'; break; next we look @ my main.tpl <span class="txt_body" id="count">{$data.end_date}</span> <script> //change the text below to reflect your own, var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") function countdown(yr,m,d) { 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==1) { document.getElementById('count').innerHTML ="expired"; return } else document.getElementById('count').innerHTML="Only "+dday+ " D, "+dhour+" H, "+dmin+" M, and "+dsec+" S remaining " setTimeout("countdown(theyear,themonth,theday)",1000) } //enter the count down date using the format year/month/day var A = document.getElementById('count').innerHTML; var myArray = A.split('-'); var yr = myArray['0']; var m = myArray['1']; var d = myArray['2']; countdown(yr,m,d) </script> so basically, in your code you would more than likely echo out the date you want counted down.. hope it helps ya out. Quote Link to comment Share on other sites More sharing options...
lasse48 Posted July 30, 2010 Author Share Posted July 30, 2010 thank you alot radar i will have a look at it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.