Closing PopUp/Window at end of PHP script

Hi people,

don’t be afraid of the PHP in the subject it’s definitely a JS question :slight_smile:

I try to close a (popup)window at the end of a piece of PHP code, why is this? Before the windows is closed a MySQL query has to be done.

in preference the window has to close without clicking an extra time.

this is what I was trying:

   $query = "UPDATE ledenlijst SET edited='$login', lid='0' WHERE ID = '$delid'";
    $ok = mysql_query($query);
    if(!$ok)
    {die('MySQL error'.mysql_error().'<br>');}
    echo('JavaScript:eval(window.close(););');

this has only as a result that the JS line:

JavaScript:eval(window.close(););

is echoed in the window but not executed…

I tried without the eval(); too, but that doesn’t work either. I understood that eval(); is executing code??
I’m not at all an expert in JS so probabely I’m just forgetting something here.

thx in advance,
greetz,
koen

Nevermind,

made a little work around :slight_smile:

Since I make page content vary with php I did this:

change <head> section depending on the outcome of an if statement with this:

<script type='text/javascript'>function CloseWindow(){window.close();}</script>

then I do my SQL query

then I change the <body> section with another if statement to:

<body OnLoad='CloseWindow()'></body></html>

and voila

any questions? just shoot :slight_smile:

greetz,
koen