Incorporating Javascript into PHP

Project Lead:

mak3mirz (5 credits)

 

Bounty:

US $4.55(Sponsor Project)

Goal funding:

More Less
Liveoffcamp.us is an off-campus housing MatchMaker site. Users such as students or landlords will fill out a simple form, stating what type of property they are looking for, or what type of property they are trying to rent out. A php script is written so that this information is saved inside our database, and in the future, if any categories match, an email will be sent out to the user, telling them where the address location is, and the landlords contact information. I have created an Virtual Earth Map page that will help the user see where the location is.
 
Note: You can propose changes using the forum below.
Liveoffcamp.us is an off-campus housing MatchMaker site. Users such as students or landlords will fill out a simple form, stating what type of property they are looking for, or what type of property they are trying to rent out. A php script is written so that this information is saved inside our database, and in the future, if any categories match, an email will be sent out to the user, telling them where the address location is, and the landlords contact information. I have created an Virtual Earth Map page that will help the user see where the location is.

I am working on implementing a hyperlink into the matched listing emails. The hyperlink is set, so that when the person clicked on the address, a pop up window appears and brings them to the VE page I have created, that shows where the address and property is. The way I am approaching this is, that I encode the address into an URL safe format and by using the php $GET method, I will be able to extract and decode the address and use it to do a search with Virtual Earth.
 
The URL of the webpage is: http://www.liveoffcamp.us/VEtest/test7.php , with this link just by itself and without any address input, will create a popup saying the location can not be found.
 
With an URL of: http://www.liveoffcamp.us/VEtest/test7.php?find=295%20Hagey%20Blvd.%2C%20Waterloo%2C%20Ontario
the location of 295 hagey blvd. waterloo , is found.
By adding the address after the find=, and encoding it with javascript function escape() it works.
 
The problem is I don't know how to script this in my php files.
 

I have gotten really close and I believe the problem with this is in just one line of code.
So far with these lines of code (skipped alot on lines inbetween):
function TableBuild(&$table, $param, $value) {
   $table = str_replace($param,$value,$table);
    return $table;
 
$table = $this->TableBuild($table,'@Address','<a href="www.Liveoffcamp.us/VEtest/test7.php?find=' . rawurlencode($property->GetAddress()) . '">'.$property->GetAddress().'</a>');
 
There are 2 problems:
If the address was, 69 Blythwood Rd Waterloo, ON N2L 3Z9
It produces a hyperlink: http://www.mytrashmail.com/www.Liveoffcamp.us/VEtest/test7.php?find=69%20Blythwood%20Rd%0D%0AWaterloo%2C%20ON%0D%0AN2L%203Z9
As you can see, the problem I have here is that, depending on what email account I use, in the beginning of the hyperlink, it would always include that emails account website (ex: mytrashmail).
 
Another problem that I have is that, I want to use the javascript "escape()" function instead of the php "rawurlencode()" function. I want to do that is because, using the $GET method, requires the address to be encoded with the javascript escape function. And there is no php equivalent of that. So is there a way to write this line, that will allow me to add in a javascript function into php?
I have tried things like:
$encoded = echo '<script language='javascript'> escape($property->GetAddress());</script>';
$table = $this->TableBuild($table,'@Address','<a href="www.Liveoffcamp.us/VEtest/test7.php?find='.$encoded.'">'.$property->GetAddress().'</a>');
And that doesn't work.

Attached are the two files I'm working with. One is the PHP code, that sends the matches listing and sends out the email.
The other is the Virtual Earth web page I have built.

Thank you very much
EXTREMELY URGENT PROJECT by mak3mirz on Thu, Aug 14, 2008 @ 12:55 EDT
A few notes by jjgignac on Thu, Aug 14, 2008 @ 13:35 EDT
hyperlink by bsnow on Thu, Aug 14, 2008 @ 13:51 EDT
jsencode function by jjgignac on Thu, Aug 14, 2008 @ 13:55 EDT (1 reply)
FOSS Factory Source