0

ok folks,

I have created a PHP page that is querying a database, and through a whileloop, displays the contents of that database table with a REMOVE and PUSH button. The REMOVE button removes it from the database entirely, and the PUSH button pushes that entry into another database and sets a variable that the entry has been pushed.

What I'm running into is that I can't quite get the page to refresh, in turn running an new query of the first database and displaying only those entries that have not been removed or pushed.

I can only get the query to run correctly if I manually refresh the page, whether it be F5 or control+r (command+r).

What is the proper way to refresh the page so that the query will run again on page load?

filype
  • 8,034
  • 10
  • 40
  • 66
Murphy1976
  • 1,415
  • 8
  • 40
  • 88

3 Answers3

2

If you want to reload the page using Javascript, try this:

window.location.reload(true);

You can also see this answer: How to reload a page using JavaScript?

Community
  • 1
  • 1
Nick Clark
  • 4,439
  • 4
  • 23
  • 25
  • It should be window.location.reload(true). window.location.reload(false) loads the page from browser cache which seems like the opposite of what the poster wants. – Jan Apr 12 '12 at 11:16
  • Well, the page is reloading, BUT it still won't refresh the query unless I F5 the page. Any other solutions? – Murphy1976 Apr 13 '12 at 01:04
  • Without seeing more of your code, I'm not sure I can be much help. If possible, try to simply everything on the page so you can narrow in on what is wrong or causing this weird behavior. – Nick Clark Apr 13 '12 at 02:47
0

there are two ways

If putting extra load on db is not a problem, use jquery methods likes $.get()

$.get('url',{},function(data){
//load results in appropriate div;
});

If you don't want to put any extra load on database just hide the row when it is removed or pushed.

$('.remove').click(function{
    $(this).css('display','none');
});

similarly make it for pushed

Krishna Deepak
  • 1,735
  • 2
  • 20
  • 31
0

Do you have some extreme caching setup on your web hosting solution?

If maintaining nice-looking URLs on this page is a non-issue you could always set a timestamp in PHP and append it to the string.

I'm not big on PHP but a javascript example would look something like this.

ts = new Date();
urltorefresh += '?timestamp=' + ts.getTime();
location.href = urltorefresh;

This would make sure the page is absolutely not in the browser cache since this specific URL have never been requested before.

Jan
  • 5,688
  • 3
  • 27
  • 44