+ Reply to Thread
Results 1 to 5 of 5

Thread: saving to database after few seconds

  1. #1
    Newbie iory is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    3

    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. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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.

  3. #3
    Newbie iory is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    3

    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

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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?

  5. #5
    Newbie iory is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    3

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Tutorial: Storing Images in MySQL with PHP
    By Jordan in forum PHP Tutorials
    Replies: 43
    Last Post: 01-16-2010, 10:35 AM
  2. Tutorial: Java Database Connectivity
    By Jordan in forum Java Tutorials
    Replies: 1
    Last Post: 10-08-2008, 04:26 AM
  3. linking SQL database with C# problem
    By Siten0308 in forum C# Programming
    Replies: 14
    Last Post: 07-02-2008, 05:50 PM
  4. Doubt on database connection!!
    By sania21 in forum Visual Basic Programming
    Replies: 3
    Last Post: 12-04-2007, 11:14 PM

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