Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

PHP Ajax: Perform action when database is updated

What I want to do is, when something new comes into the database, it gets the latest value entered and plays a specific song depending on what it says.

For example, on my computer, I run this website. Say somebody else around the world picked up their phone and clicked to play a song, that song would automatically play on all devices running the page. When somebody chooses a new song, the song should change.

I have made several tries at this, mainly trying to use setInterval in JavaScript however it just updates and updates all the time as you would expect.

I guess what I really am looking for is a way to track when the database has been updated, any solutions or code examples I can use? Thanks a lot good old Treehouse community!