Jump to content


Photo

java and php call


  • Please log in to reply
3 replies to this topic

#1 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 10 April 2006 - 11:51 AM

ok i want to make it so i can insert the time some one spent on a page in to a mysql data base the code i have is

  <script  language="javascript"  type="text/javascript">      
<!-- Begin
pageOpen = new Date();
function bye() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
seconds = (pageClose.getSeconds() - pageOpen.getSeconds());
time = (seconds + (minutes * 60));
if (time == 1) {
time = (time + " second");
}
else {
time = (time + " seconds");
   }
alert('It has been ' + time + '.  ');
}
window.onunload = bye;
// End -->
</script>

how can i turn the java var ' + time + ' and make it into a in a $statment.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 10 April 2006 - 01:56 PM

Php runs on the server so cannot mix with javascript (client-side) as you have descibed. You will need to have the javascript code request your php script from the server, or maybe look into using ajax.

#3 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 10 April 2006 - 03:04 PM

ohh do you know of a php script that can genarate the time you have been on a cetian page?

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 10 April 2006 - 03:54 PM

You could do it with a custom session handler, but its no simple script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users