[RESOLVED] using onMouseover in php

wxdqz

New Member
I have a mySQL database that holds name and address information. My page displays an ordered list of surnames. I would like to generate an alert box that shows the 'first name' onMouseover of a surname in the list.

The following code generates the list of surnames as html anchors. The onMouseover works but I get a javascript error message - e.g. if the name I mousedover was 'Smith' the error message says "'Paul' is undefined" (i.e. as in 'Paul Smith')

here's the code:

'first name' is held in $row[1] and surname in $row[2].

for ($i = 0; $row=mysql_fetch_row($result); $i++)
{

$name = "<a href='http://www.phpbuilder.com/board/archive/index.php/#' onMouseover='alert(" . $row[1] . ")'>" . $row[2] . "</a>";

//etc..
}


I note that this works for $row[0] but why do I get an error for elements beyond [0]?

I tried setting a variable to $row[2] and putting that in the alert, but that didn't work.
 
Top