Closed Thread
Results 1 to 5 of 5

Thread: saving to database after few seconds

  1. #1
    iory is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    saving to database after few seconds

    dear all, im newbie here
    I have this code, after user make a selection, he/she see the data that he/she selected, then, that data name will be automatically save into their record database.

    is it possible to make that, the record will be saved after user see for few seconds (ex: 5 seconds). so that it wont save immediately ( for consideration that, if user see the data for more than 5 seconds, that
    means he/she is interested, then it should be saved automatically)

    Code:
    <?php
    if ($registration>0){
     
    $qry="SELECT * FROM registration WHERE id_registration=".$registration" LIMIT 1";
     
    $exe=mysql_query($qry);
     
    $show=mysql_fetch_array($exe);
     if (
    mysql_num_rows($exe)==1){
     echo 
    "<div class='divide'>&nbsp;&nbsp;++ ".$show['title_registration']." ++</div><br />";
      
    $qry="INSERT INTO tb_history VALUES('',".$_SESSION['ID'].",'".$show['name_word']."',
    '"
    .$_SERVER[HTTP_REFERER]."','".date("Y-n-j H:i:s")."')";
    ?>
    can someone please help me with this?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: saving to database after few seconds

    No, since PHP is a server side language it processes all instructions before presenting it to the user. This means you can't have a "wait" of 5 seconds before saving using the script above. You can, however, display the data and use JavaScript timer to count down 5 seconds. Once the JavaScript timer reaches 5 seconds you could use AJAX to connect to another PHP script that runs your insert command above.

  4. #3
    iory is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Re: saving to database after few seconds

    so, that means, i cannot put the script all together in one PHP file and make a "wait" of 5 seconds before saving to database? i never thought about that before, im newbie in PHP ...thx admin for clearing this out

  5. #4
    Jordan Guest

    Re: saving to database after few seconds

    That is right. You can put the insert into a secondary script and use AJAX like I stated though. If you are a newbie this may be a little advanced. Why do you want to wait 5 seconds anyway?

  6. #5
    iory is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Re: saving to database after few seconds

    yes, i think this is really advanced for me..the reason why i want it to wait 5 seconds before saving into the database is because, the result of this script will be [title_registration] <- it is a data name, so im thinking, if user checked the "data name", i want it to be save into user record history, for later use. Maybe next time user check his record, he can see that he checked this "data" before. But user maybe just clicking without paying attention to this data name.

    Thats why, i want it to be saved after few seconds, for considerations that, if user really interested about that "data", he should at least see and checked for few seconds.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-23-2011, 03:02 PM
  2. saving data in a database
    By ployo60 in forum Pascal and Delphi
    Replies: 7
    Last Post: 02-20-2011, 11:44 AM
  3. Creating inputs onfly and database saving
    By Ficoder in forum PHP Development
    Replies: 0
    Last Post: 02-14-2011, 07:16 AM
  4. Saving a excel file to Oracle Database using vb6.0
    By catchsyed in forum Visual Basic Programming
    Replies: 4
    Last Post: 05-04-2009, 03:07 PM
  5. Saving session into database and use it
    By yonghan in forum PHP Development
    Replies: 9
    Last Post: 02-22-2009, 04:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts