This topic is locked
[SOLVED]

 visual editor - adding code

7/15/2007 11:09:41 AM
PHPRunner General questions
P
phpwalker author

i have a project in php3.1 and currently have some code that i always add after the pages for the project are generated.
I open the file ..._edit.php file, locate this line:
$data=db_fetch_array($rs);
and add following code after it:
echo "<a href=\"http://www.whitepages.com/15055/search/FindPerson?firstname=&".$data["FirstName"]."&name=".$data["LastName"]."&where=".$data["City"].",PA\">Look up phone</a>";
I am wondering if I can use the visual editor to do this for me instead so i don't have to re-enter this line every time i generate my project. I tried adding above surrounded by <?php and ?> but that didn't work... then tried

<a href="http://www.whitepages.com/15055/search/FindPerson?firstname=&".$data["FirstName"]."&name=".$data["LastName"]."&where=".$data["City"].",PA">Look up phone</a>
but that didn't work either (i guess because this line is not pure HTML - but also has some php variables? not sure...
any help would be appreciated

Sergey Kornilov admin 7/15/2007

Use EditOnLoad event for this purpose.

P
phpwalker author 7/15/2007

Use EditOnLoad event for this purpose.


added the following to OnLoad event to my edit page:
function EditOnLoad()

{

global $where;

// Parameters:

// $where - string with WHERE clause pointing to record to be edited

//** Display a message on the Web page ****
echo "<a href=\"http://www.whitepages.com/15055/search/FindPerson?firstname=&".$data["FirstName"]."&name=".$data["LastName"]."&where=".$data["City"].",PA\">Look up phone</a>";
}
but received this error:
PHP error happened
Technical information

Error type 8

Error description Undefined variable: data

URL www.xxx.com/votersv2a/Voters_NEW_edit.php?editid1=009353516-15

Error file /home/xxx/public_html/votersv2a/include/Voters_NEW_events.php

Error line 10

SQL query SELECT `voters`.`voterID`, `voters`.`LastName`, `voters`.`FirstName`, `voters`.`MiddleName`, `voters`.`Suffix`, `voters`.`Phone`, `voters`.`PhoneNotes`, `voters`.`email`, `voters`.`houseNum`, `voters`.`Street`, `voters`.`City`, `voters`.`State`, `voters`.`Zip`, `voters`.`Moved`, `voters`.`MovedFromGroup`, `voters`.`Deceased`, `voters`.`Neighborhood`, `voters`.`MailingAddress`, `voters`.`MailingCity`, `voters`.`MailingState`, `voters`.`MailingZip`, `voters`.`VPrecinct`, `voters`.`VCommitteePerson`, `voters`.`Party`, `voters`.`Active`, `voters`.`Hot`, `voters`.`DemSupport`, `voters`.`DemSupport1`, `voters`.`Notes`, `voters`.`sex`, `voters`.`group`, `voters`.`ModifiedBy`, `voters`.`DOB`, `voters`.`AptNo`, (YEAR(CURDATE())-YEAR(DOB)) - (RIGHT(CURDATE(),5)

J
Jane 7/16/2007

Hi,
you need to declare $data array before:

function EditOnLoad()

{

global $where;global $data;
echo "<a href=\"http://www.whitepages.com/15055/search/FindPerson?firstname=&".$data["FirstName"]."&name=".$data["LastName"]."&where=".$data["City"].",PA\">Look up phone</a>";
}