embedding JavaScript in php
I had lots of problems while doing this. But after trial and error it now works. So here you go, save time and make new mistakes. This one is solved.
Sample code
Task was to close the popup window after the php script updates the database with the form values.
if($submit){
$connection = mysql_connect("localhost", "username", "password") or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection) or die("couldn't select database");
$query = "UPDATE $table_name SET mon=\"$mon\",tue=\"$tue\" WHERE id=\"$id\"";
$result = mysql_query($query,$connection) or die ("no i couldn't execute query");
echo "<script language=\"JavaScript\">\n
<!--
window.close();\n
//-->
</script>";
}
?>