Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Times Problem

  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Thanked 0 Times in 0 Posts

    Times Problem

    So i want to select information from database and after 20 second when file has opened write another information in that row.

    i wrote such code:
    PHP Code:
    mysql_query("SELECT * FROM news WHERE id=5");
    $time time();
    $insert mysql_query("INSERT INTO news SET last_time = '$time'");
    $time2 time() + 20;
    $last_time mysql_query("SELECT last_time FROM news WHERE id = 5 ");
    $time2 $last_time){
    $addshows mysql_query("INSERT INTO news SET shows = 2");
    but it is not working how i can to work this script? or is another way to make such script?

  • #2
    New Coder
    Join Date
    Dec 2005
    Thanked 1 Time in 1 Post
    Because PHP is server side as far as im aware this is not possible, the server reads the php and then executes it. There is not wait command, therefore the best way to do this would be with HTML.

    If you google HTML refresh it should come up with something. I cant remember the exact code and I cant get to it here. Post back if you can or cannot find it and if not I will post it when I get home.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Florida, USA
    Thanked 406 Times in 398 Posts
    Well, you could use flush(); to send the output and sleep(20); to wait, but PHP is not the best way to do this because you'll either hit the loading time limit or you'll have to circumvent it, and that will cause more problems than solutions. If the information is static you can load it into Javascript vars and then use it to display them every 20 seconds.


    Posting Permissions

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