php - javascript

A

Anonymous

Guest
you would have to make input tags within a form and use JS to set those values.. then submit the form and put the info into a db
 
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.

Happy PHP-ing!
 
Back
Top