PHP/Javascript Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

PHP/Javascript Question

Post by tpra21 »

I am using a Google Maps API to calculate the distance between two addresses. Unfortunately, I need to do this in a loop for several thousand to/from address combinations and then store the distance (miles between two addresses) into a variable and then a database. My issue is getting the Javascript variable into the PHP variable over and over without refreshing the page (passing it through a form or URL).

Hopefully I am explaining my issue clearly. Below is the basic idea.

Code: Select all

read through DB get from address
     read through and process all to addresses with from address
          javascript distance var = google API result (this line is echoed/embedded javascript in PHP)
          place javascript distance var into PHP distance var for later iserting into DB
     end read
end read
I have looked all over th einternet. Any help or ideas would be awesome.

Thanks,

Adam
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: PHP/Javascript Question

Post by alex.barylski »

Use AJAX to send the value to a PHP script on each iteration

OR

Cache the results in a JavaScript array and when finished submit the whole enchilada
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

Re: PHP/Javascript Question

Post by tpra21 »

Thanks for the reply. Although new to Ajax, I think I will do some reading and give that approach a shot. It sounds like an awesome technology. I know I am using some Shadowbox software on my site now, and it is very impressive.
Post Reply