title: Pass data from php foreach loop to javascript
body: <p>Im trying to add javascript countdown into a table, which this table was locate in php foreach
  <br/>
  My php code goes like this:</p>
  <pre><code>&lt;?php
      global $wpdb, $indeed_db;
      $user = wp_get_current_user();
      $userid = $user-&gt;ID; 
      $woo_orders = $wpdb-&gt;get_results(&quot;SELECT * FROM wp8u_wc_order_product_lookup&quot;);
      foreach ($woo_orders as $print ){
          $order_id = $print-&gt;order_id; 
          $woo_customer_id = $print-&gt;customer_id;  
          $woo_customer = $wpdb-&gt;get_results(&quot;SELECT * FROM wp8u_wc_customer_lookup where customer_id=$woo_customer_id&quot;);
          foreach($woo_customer as $print2){
              $current_user_uid = $print2-&gt;user_id;
          }
          $date1 = strtotime($print-&gt;date_created);
          $date2 = strtotime(&quot;+1 months&quot;, $date1);
          $date_created = date('Y-m-d H:i:s', $date1);                                    
          $date_after = date('Y-m-d H:i:s', $date2);                                   
          $amount = $print-&gt;product_net_revenue;                                                                      
          if($userid == $current_user_uid){                                               
                  ?&gt;&lt;table&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Order ID&lt;/th&gt;
                          &lt;th&gt;My ID&lt;/th&gt;
                          &lt;th&gt;My Customer ID&lt;/th&gt;
                          &lt;th&gt;Create Date&lt;/th&gt;
                          &lt;th&gt;Date After 1 Month&lt;/th&gt;&lt;
                          &lt;th&gt;Amount&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;?php echo &quot;$order_id&quot;;?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo &quot;$current_user_uid&quot;;?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo &quot;$woo_customer_id&quot;;?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo &quot;$date_created&quot;;?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo &quot;$date_after&quot;;?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo &quot;$amount&quot;;?&gt;&lt;/td&gt;
                          &lt;td id=&quot;demo2&quot;&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;&lt;?php
               }
  }
   ?&gt;
  </code></pre>
  <p>This is my output before for the above php code:</p>
  <pre><code>Order ID |  My ID | My Customer ID |    Create Date         |   After 1 month       |   Amount   |   Timer  |
  126         37          9               2020-06-24 13:45:35     2020-07-24 13:45:35     3000
  Order ID |  My ID | My Customer ID |    Create Date         |   After 1 month       |   Amount   |   Timer  |
  123         37          9               2020-06-22 12:01:14     2020-07-22 12:01:14     1000    
  </code></pre>
  <p>so im trying to add countdown timer to both row under &quot;Timer&quot; Column
  <br/>
  and this is my java script countdown timer code:</p>
  <pre><code>&lt;script&gt;
      function createCountDown(elementId, date){
          var countDownDate = new Date(date).getTime();
          var x = setInterval(function(){
              var now = new Date().getTime();
              var distance = (countDownDate) - (now);
              var days = Math.floor(distance / (1000 * 60 * 60 * 24));
              var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
              var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
              var seconds = Math.floor((distance % (1000 * 60)) / 1000);
              document.getElementById(elementId).innerHTML = days + &quot;d &quot; + hours + &quot;h &quot; + minutes + &quot;m &quot; + seconds + &quot;s &quot;;
              if (distance &lt; 0)
              {
                clearInterval(x);
                document.getElementById(elementId).innerHTML = &quot;SUCCESS&quot;;
              }
          }, 1000);
      }createCountDown(&quot;demo&quot;, &lt;?php echo &quot;$date_after&quot;; ?&gt;)
  &lt;/script&gt;
  </code></pre>
  <p>How do i add this javascript countdown timer in to the table ?</p>