php - Best way to alert user -
i have database table called userbadges . users have badges @ level 0 "locked" (greyed out) . can unlock @ level 1 , way level 3. each level worth points.
userbadges {user_id,badge_id,level,score,seen}
what best way me alert user
- a) have unlocked new badge
- b) have leveled badge
i have code , doesn't seem right. counts number of new badges ():
function countnewbadges() { require "connect.php"; $newbadges = mysqli_query($connection,"select users.studentid, individualbadges.badgename, ub.level, count(ub.seen) total userbadges ub inner join users on users.id = ub.user_id inner join individualbadges on individualbadges.id = ub.badge_id studentid = '".$_session["studentid"]."' && seen=0 && level!=0") or die(mysqli_error($connection)); while ($data = mysqli_fetch_array($newbadges)) { echo $data['total']; } }
i have code set seen field of badges table 1.
i make messaging system: create table message text, title. (for every message have or dynamicly) make table user_has_message got 2 keys join, , boolean if read.
with simple select * user join user_has_message on ... , iduser = ... join message on ... read = false
alerts/messages specified user.
edit: can add entry user_has_entry
, in specify user
should message
.
now have possibilities: add date default now(), know when message occoured, give user possibility delete message (what deletes entry on user_has_message
), add tho option mark message unread, etc etc ...
shure can use messages other things welcome-message etc. or add cronjob send email users open messages older 5 days. or implement chat-system...
Comments
Post a Comment