I have implemented an observer pattern within my code that observes a certain state. If this state is changed, processReceivedData()
is supposed to refresh multiple pages at the same time if they are opened in the browser (or in general, update multiple pages where the observed state is used).
public function processReceivedData() {
//header("location: ".$_SERVER['PHP_SELF']);
header("Refresh: 0; url=".$_SERVER['PHP_SELF']);
}
It will only reload the current page I am on and I understand why (How would the other browser window know there has been a change when the algorithm is already done and PHP
is not dynamic?)
How can I reload the other pages, too and on change? They all use the same observer and observed and on change this function is called
public function setState($newState, $_PizzaID) {
if($this->db->query("UPDATE bestelltepizza SET status='$newState' WHERE PizzaID = '$_PizzaID'")) {
parent::notify();
} else {
$this->state = "Unable to connect to database via setState(); method";
}
}
I can't think of a proper way to solve this as I don't know all possibilities of PHP
and if this is possible with only PHP
or if it would only work with javascript
or else.
If I failed clearing out my exact problem or if any questions pop up to my question, please comment and I will clarify. Help very much appreciated, thanks.