That really depends. Usually you'd just query to see if there are any new notifications for the user on each page (like the menu part of your code), and if so use the appropriate CSS. Like for bootstrap: http://getbootstrap....ponents/#badges
hmmm. thanks. but how can one query for new notification thats the issue. doing a select alone can't get the new notification. my idea is you have to have a last count and any other entry that follows will be deemed as new. but the problem is I can't codify it.
You have a table to store users who sign up to become referrers. When you decide that they have reached a certain level you post that value to their "referrer" record. And so on. I assume that you rate them at a certain level for all people that they refer or for all products that they can be referring. If not, you have to create a referrer record for each user for each category (not level) of referral they make in the same fashion.
Obviously the referrers must login before referring someone. Periodically you go through your table (monthly?) and look for referrals made since the last-paid date on the record and report out (or store) the referrer's name/id and the amount to be paid this time and post that record with the current date as the last-paid date. You might also save the total amount earned over time.