They all create popups depending on the situation xD JS and jQuery work with HTML. For example jQuery can be used to interact with HTML's tags. In the php example, if you use it say in the my adopts php page, it will activate an popup with the message "OMG2" as soon as you click on the page's title ( $('h1').click(function(){***code***}) <- when a h1 HTML element is clicked it creates a new function and does whatever the function should do).
There are many other functions besides click (when mouse hovers, when form's input field is selected, when submit button is clicked, etc).
The other JS function works whenever it is called. It can be called normally or on certain events (<body onload="alertme()"> when the body loads, calls the function).
That way you can check when someone clicks a button and it will change something in the page automatically. You can add HTML elements and change them (even their CSS!). For example with this $('div').append('<div>NEW DIV</div>') it will add a new div to the page without refreshing after div (like so
http://api.jquery.com/append ).
However, to check the DB you will need ajax as well x.x but you most likely can use it, since jQuery works