Solved

countdown timer based on server clock and php variable from SQL database

Posted on 2006-07-03
3
617 Views
Last Modified: 2012-06-27
I need to create a 'live' countdown timer on my page, which counts down the difference between the server clock, and a unique date and time held on an SQL database.  Different users will have different times in their profiles, so the timer needs to act upon a variable called from the SQL database.  I know a bit of PHP but no javascript, and am wondering if this is the right language to use to solve my problem?  

I am hoping I can copy a simple javascript countdown code from somewhere, and insert php to call the variable (i.e. instead of writing "2006" in the javascript for the clock, I write in a php tag with an echo call to the $variable), but am unsure if the languages will work together in this way.

Any tips on where to look, how to approach this problem would be most appreciated.  
0
Comment
Question by:RowdyBurns
3 Comments
 
LVL 12

Accepted Solution

by:
AmigoJack earned 500 total points
ID: 17030775
php is processed before it leaves the server.
javascript is processed after it has reached the client.

that said you can do whatever you want. if you do somewhere an echo("hello"); it can be anywhere in the document. it doesnt matter if you previously did echo("<script>"); because php itself doesnt care.

please mind how the technologies work. php = PreHtmlProcessed, this means php is like a constant html-file which lies on a server. the only addition is that you can program something which will make the html-file being different. the OUTCOMING file itself cannot act - its still only a document and not a program. so try it like you described it yourself and then test the produced file on any client (msie, firefox, opera...)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now