0

I wanna update my database when users visiting my site , every one minute, I use this code :

 $stmt = $dbConnection->prepare( "UPDATE db1_etchat_user SET alaghe=? WHERE etchat_username=?");    
$stmt->execute(array($alaghe,$username));

I wanna every one minute that's user visit my site , my columns be updated.

Excuse me for my bad English.

4

3 回答 3

1

Make Ajax request to your server once per minute.

于 2013-09-07T14:14:37.307 回答
0

page2.php will call after every 1 minute

page1.php

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" 
type="text/javascript"></script>
<script>
function doUpdate() {
    $.ajax({
        url:"page2.php",
        success: function(resp) {
           setTimeout(doUpdate, 1000*60); //1000 = 1 minute
        }
    });
}
 setTimeout (   doUpdate, 1000*60 );
</script>

page2.php

$stmt = $dbConnection->prepare( "UPDATE db1_etchat_user SET alaghe=? 
                                                  WHERE etchat_username=?");    
$stmt->execute(array($alaghe,$username));
于 2013-09-07T14:28:58.980 回答
0

You could use a cronjob and start the php-file you want to execute.

于 2013-09-07T17:58:42.453 回答