PHP and Javascript cannot totally interact with other as they are not of the same in nature. (server-side and client-side).
But you can write javascript using PHP.
Code:
echo "
<script language='javascript'>
var data = new Array();";
$query = "SELECT * FROM Employees";
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
echo "
data[] = '$data[name]';"; // must write for example, data='Harrison Dano';
}
echo "
</script>";
You can then use the array you created in javascript to whatever you wish.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.