user1108224
user1108224

Reputation: 159

Send parameter in php to trigger page refresh 1x

I'm trying to make an app that triggers different content on a webpage based on the button pressed in the app. I need to be able to send a parameter to tell the server to refresh the video, image, and text when a button in the app is pressed....right now it changes the video/image but you have to hit the refresh button in the browser to see the new content...

Everything I've tried refreshes at an interval and it reloads the video/content repeatedly...

Currently i have 3 entries in a mysql db, and one of the fields is "active". When I press a button in the app, it sets all of the row's "active" field to 0, then it sets the record with the id of the button pressed to active=1.

In my display.php page I have it check the mysql for all records with active=1, and it works great, but I need to somehow tell it to trigger a refresh when the active record changes in the db....

The webpage will only be run one 1 machine which is running chrome, it's then displayed on a digital billboard, and I want people to be able to trigger the different content by pressing different buttons on their mobile devices...I can't figure out how to communicate with the sedna presenter software to tell it to refresh the page so was hoping to just make the webpage update itself (like with ajax but for video/image) and the sedna simply displays the webpage like a view in MVC pattern.

Would an iframe help?

Upvotes: 0

Views: 551

Answers (1)

brendosthoughts
brendosthoughts

Reputation: 1703

So basically your going to want to add a new php script on the server which looks for the change in your mysql table on the field active (as an aside there is a better way to do this then repeteadly checking though I can't recall how). Then have your javascript function poll this script. using this method again:

  window.setInterval(function(){ /// call your function here }, 100);

Have the php script return a 0 or a 1 to indicate if active has changed. then check this result in your java script if active has changed reload the page with a get request to the display.php script ... if you want some help with the code I can post somethng in a bit... I'm just eating lunch and on a mobile so it will take a bit of time

Upvotes: 1

Related Questions