How can I use Web Sockets with PHP to limit what chat displays on database results
===

I have a basic knowledge of websockets and I've set a web socket sever up on my VPS host.

I have a user system with database. I was planning on having a table called 'chat_log' too.

I want to use my web socket sever on different pages.

Say for example on each user's profile there was a chat. 

I'd have a column in the database of to where the chat was posted to. 
Then it would run a query to check where the chat was posted to, if it was posted there display it.

Could I achieve the same effect (combining PHP Database techniques) with web sockets to create a chat based on database results?


Thank you so much! I appreciate your help!