How to make it a function to apply it to a PHP variable?

Asked

Viewed 66 times

1

<script>
    jQuery(function($){
        $('#timer').countdown({
            until: new Date("2015-11-04 12:00:00"),
            compact: true
        });
    });
</script>

I need to transform the above code in a function and then apply this function to a PHP variable that is inside a loop. How to do this?

while ( $linha = mysql_fetch_array($query) ) {

     echo $datafinal;           // Y-m-d h:i:s

}
  • 1

    http://answall.com/questions/90095/posso-fazer-o-javascript-escreverphp you cannot send js variables to php

  • And there’s another solution @Amadeuantunes?

  • you can send the date from php to js so the date would be a php variable and could use it below, you can use AJAX but I don’t think it would be necessary

  • Is that what you want? http://answall.com/questions/58958/passar-vari%C3%A1vel-php-para-javascript

  • I need within a retrieved date loop in the database to implement a Countdown. How could I do this personal? http://axitech.com.br/ccl/

  • You can send your function output to PHP.

  • I found it interesting but I didn’t understand it very well. Can you explain it to me @Ivanferrer? I think this can solve.

  • @Marcosvinicius, I put the solution in response.

  • And what is your question regarding the answer?

Show 4 more comments

1 answer

2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.