code for Updating a query when the browser is closed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gmanoj4u
    New Member
    • Jun 2007
    • 2

    code for Updating a query when the browser is closed

    hi all,
    i am manoj i have a problem with my project ,i need a code to update a mysql query when the browser is automatically closed (in php).kindly suggest me its important for me
    thank u ..manoj
  • ronnil
    Recognized Expert New Member
    • Jun 2007
    • 134

    #2
    autmatically closed, as in some function you created forces the window to close?

    in that case you would probably want to use AJAX to connect to a php file and execute the query.

    bear in mind that PHP is a serverside language, meaning php has no knowledge of what you might do with/in your browser.

    Comment

    • gmanoj4u
      New Member
      • Jun 2007
      • 2

      #3
      Originally posted by ronnil
      autmatically closed, as in some function you created forces the window to close?

      in that case you would probably want to use AJAX to connect to a php file and execute the query.

      bear in mind that PHP is a serverside language, meaning php has no knowledge of what you might do with/in your browser.


      hi ronnil thanks for the reply ,i need to know weather is it possible using java script or not & need a small help from u that i have no knowledge about ajax so if possible can u send me the code to be used in php...
      thank u ..

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #4
        the php code would merely be:

        <?php
        $sql = "UPDATE sometable set somerow=someval ue";
        //your sql query
        ?>

        check out the link in the prior post, it gives you enough knowledge to use AJAX, if you're afraid of learning a new language... don't worry, it's just a way to use implemented functions of javascript :)

        I don't think you can make up a proper working solution with javascript. You would need to use an event called onclose event, which ain't there as far as i know.

        If this window is opened by another window you control, you can in the opener however make a loop checking if the window is open, when it's not no more, perform the query (using AJAX ;))

        Comment

        Working...