<?php
$hostname = "localhost";
$username = "hi";
$password = "bye";
$dbid = "jesus";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$name1=$_REQUEST['name1'];
$result=("SELECT name FROM lydia WHERE nam='$name1'");
while($myrow = mysql_fetch_array($result))
{
$first=$myrow[0];
echo $first;
}
?>
<html>
<head>
<script type="text/javascript">
function win()
{
var c='<?php echo $first; ?>';
alert(c);
}
</script>
</head>
<body>
<form name="form1" method="get" action="<?php echo $PHP_SELF;?>" onSubmit="javascript:win();">
NAME<input name="text" name="name1">
<input type="submit" value="submit">
</form>
</body>
</html>
in this code i want to alert the $first variable.javascript executed before php.is there any solution alert the variable in script.