Jump to content

Update row when 30 seconds passed


Cyto

Recommended Posts

Hi,

 

I want to update a row when 30sec are passed on a page. If not nothing happens(not updating row).

 

Example:

You go to example.php>> 30sec pass, update row>> 30sec not over, no update.

 

it does not necessarily have to be second it can be minutes or hours.

Who can help me?

 

Hope its clear enough, Thanks.

Link to comment
Share on other sites

Do you want the update to occur if the user is still viewing the page after 30 seconds?  In that case I would use ajax with a timer.

 

If you want it to act more like a timeout, where something occurs unless the user does something within a time limit, then you could store a timestamp in the database.  When they take the required action you check the timestamp and see if it's more than 30 seconds old.  In this case the action won't occur exactly after 30 seconds, but maybe that doesn't matter.  It depends on the reason for the 30 seconds.

Link to comment
Share on other sites

This might be the time to learn ajax :)  It's actually very simple if you use jquery.  It can be as simple as this:

 

$.get('mark_user_as_timed_out.php');

 

You would want to have that executed after a 30 second delay, using javascript setTimeout(), such as at http://www.htmlite.com/JS018.php .  What will happen is the user's browser will run that php script, but their page won't be updated (unless you want it to be).

Link to comment
Share on other sites

This might be the time to learn ajax :)  It's actually very simple if you use jquery.  It can be as simple as this:

 

 

$.get('mark_user_as_timed_out.php');

 

 

You would want to have that executed after a 30 second delay, using javascript setTimeout(), such as at http://www.htmlite.com/JS018.php .  What will happen is the user's browser will run that php script, but their page won't be updated (unless you want it to be).

 

 

Would you mind explaining it further, getting confused :confused:

 

$.get('mark_user_as_timed_out.php'); Is jQuery i know that its like including a php file.

 

But the JS part is where i got stuck. How am i going to set a update row with JS on mark_user_as_timed_out.php?

thanks for your comments much appreciated.

Link to comment
Share on other sites

What you would do is create a php script called "mark_user_as_timed_out.php".  That script is php, so it can do anything you want, including updating the database, which you couldn't do directly from JS.  If you have the user's information in a session then you can use that in mark_user_as_timed_out.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.