Hi all, I have just created a social site and i was wondering if there is a way to make notification pop up on the side of screen and fade just like facebook? but in php?

Please add links to other website to help me get on the right path. Thanks so much!!! =D

What do you mean "in php"? With php, you can do things on the server side. Notifications are shown on the client side.

Member Avatar for diafol

JS is what you're looking for. Depends how you want to do this. Do you want instant notifications, so if user on same page, you get notification when it arrives. For this you need Ajax - js call every 30s say to a php script which polls the DB. If new notifications, send data back to JS, which updates the page. JS could also trigger a faux popup (like a lightbox or jQueryUI-like dialog).

@ardav - Yes I want an instant notification - Where can i find information about the AJAX that is needed or the JS that is needed im kinda new to AJAX =D Thanks!

Member Avatar for diafol

It's an idea to familiarise yourself with what ajax actually does first of all. BTW, you can use this with a mix of languages/markup - it doesn't have to be php - could be asp etc.
Then once you think you've got a good grasp of the basics, have a look at jQuery ajax methods. This should significantly simplify things for you. jQuery is a small library (about 90kB in min. form).
The benefits of using this is that jQueryUI is built upon it and using it to deal with popups, lighboxes etc should be simple. Far better than cobbling different pieces of code together. However, these aren't the only players in town. ExtJS for example has some beautiful UI elements.

If I was going to build this type of system, I think I'd use jQuery since it is very well supported and has a million plugins. Almost everything you need to do has been tried and can be found online somewhere. If not, there are some really good contributors on the jQuery forum. I've had loads of good advice from them.

So my take:

JS
setinterval to every 30 seconds (or minute) - too many ajax calls will kill your server
this setinterval runs a js function.
the js function runs a php file, which queries the mysql db for a new msg.
if there are new entries, return the data (I'd use json myself, or you could just paste some html, or whatever else you fancy) to the js script.
the js script then deals with the data, possibly formatting it before inserting it into the page, e.g. as a red flag with numbers on a link (like FB).

You could even have it place the latest msg in a sidebar or scrolling widget. The choice is yours. You're pretty much only limited by your imagination (oh, and users who do not have js turned on).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.