By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

how can add php file into javascript file

P: 1
this is my script

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.             var numberOfClicks= [];
  4.             alertTime = 0;
  5.  
  6.             $(document).click(function(){
  7.         if(numberOfClicks.length < 5){
  8.            numberOfClicks.push(new Date().getTime());
  9.         }else{
  10.             console.log(alertTime)
  11.             var diff = numberOfClicks[numberOfClicks.length -1] - numberOfClicks[0] - alertTime;
  12.             console.log(diff);
  13.             if(diff < 10000){
  14.                 var beforeAlert = new Date().getTime();
  15.  
  16.  
  17.     alert( "tommy!");
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                 var afterAlert = new Date().getTime();
  25.                 alertTime = afterAlert - beforeAlert;
  26.              }
  27.             numberOfClicks.shift();
  28.             numberOfClicks.push(new Date().getTime());     
  29.             console.log(numberOfClicks);
  30.         }
  31.  
  32.     });
  33.  
  34. </script>    
i have add after alert box following php file

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3. require_once("connection.php");
  4. //$id=$_SESSION['SESS_MEMBER_ID'];
  5.  
  6. $query="SELECT lastlogin FROM users WHERE id=2"; 
  7. $result = mysql_query($query) or die();
  8. $row=mysql_fetch_array($result) ;
  9. ?>  <?php
  10. date_default_timezone_set('Asia/Kolkata');
  11. $Ftime=$row['0'];
  12. $Stime=date('Y/m/d h:i:s',time());
  13. $dif=strtotime($Stime) - strtotime($Ftime);
  14.  
  15. ?>
please give mi solution.
Feb 13 '16 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
how can add php file into javascript file
you canít.

you can make PHP create a JavaScript file, but thatís about it.
Feb 13 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.