Need to click the refresh for new data..

Discussion in 'PHP' started by victor205, May 3, 2012.

  1. #1
    Im working on a script for a simple top five, I get the data from MySQL and then output it in a table..

    And i get this:
    refreshyb.png

    But when I delete the data from the database or i change something in the database, it doesnt update it automatically, I have to click F5 or clear the cache in order to see the new data..

    How can i resolve this problem ?
     
    victor205, May 3, 2012 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    are you talking about the page displayed doesn't auto-adjust the info?
    Or even when you reload the page it doesnt show the change?
    If so, the data wont change without a page reload unless you're using AJAX , and if you are reloading your page a couple times, that's your browser setting = 'check for new content every time'
     
    ezprint2008, May 4, 2012 IP
  3. 137th Gebirg

    137th Gebirg Active Member

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    You could also play with the META tags to adjust how the browser cache behaves but, yes, AJAX is your best bet. Make sure you pass a randomly generated number into your AJAX parameter string. AJAX results can also be frequently cached - sending a random number with the call guarantees a fresh pull every time.
     
    137th Gebirg, May 4, 2012 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    for aesthetic and for use-ability I would go with AJAX. This will make it so that when a user clicks on, or updates anything the results will be immediately loaded to the AJAX display on your webpage WITHOUT any page reloads and you won't have concern with the cache settings of your visitors/users.

    I make all sorts of AJAX scripts and functionality and sell them in bulk for customizing your own systems or using whats provided.
    If you decide to go with AJAX i have plenty of copy/paste and easy customize-ables.
    let me know in IM
     
    ezprint2008, May 4, 2012 IP
  5. infotripro

    infotripro Member

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    43
    #5
    META tags do now work all the times

    Best solution would be to use AJAX as mentioned above

    You can work also with JavaScript as follows:

    Put this in the head tag.
    The script uses two cookies:
    - one to store if the page has been visited
    - one to store if the reaload has been triggered
    if(navigator.cookieEnabled){
    var visited=0;
    var refreshing=0;
    if(Get_Cookie('visited')) {
    visited=parseInt(Get_Cookie('visited'));
    }
    if (Get_Cookie('refreshing')) {
    refreshing=parseInt(Get_Cookie('refreshing'));
    }
    if(visited==1){
    if(refreshing==0){
    window.document.cookie = 'refreshing=1';
    window.location.reload();
    }else{
    window.document.cookie = 'refreshing=0';
    }
    }else{
    window.document.cookie = 'visited=1';
    }
    }
     
    infotripro, May 4, 2012 IP