Grow your CSS skills. Land your dream job.

how to make read & unread property for posts and messages with php& mysql

  • # October 31, 2012 at 2:38 pm

    Hellow Everybody

    I have been working on My CMS system and I want add to it the property of read and unread via PHP & MySQl

    is this done through session or what and how ?

    also I want make user groups with different permissions like edit , delete for users , supervisor , admins .. How this ??

    # October 31, 2012 at 3:52 pm

    That sort of info needs to be stored in the database, e.g.:

    CREATE TABLE `article_views`(
    ,`article` INT(11) UNSIGNED NOT NULL COMMENT ‘id of article`
    ,`user` INT(11) UNSIGNED NOT NULL COMMENT ‘id of user who viewed post’
    ,`time` DATETIME NOT NULL COMMENT ‘date/time when user viewed article’

    Same for making user groups: you’d need to store that info in your database, and have your scripts check to make sure the logged-in user has permission to do whatever they’re trying to do.

    Are you using a content management system, or are you trying to code something yourself?

    # October 31, 2012 at 10:16 pm

    thx traq , I build my own CMS , I want know the idea for making message unread after opening it ..

    # October 31, 2012 at 11:55 pm

    Well, that’s “the idea.” When you display the message to a user, update the database with that information. On subsequent requests, you can check those records.

    *If* by “messages” you mean something like emails or IMs, where you only need to worry about one reader (the message recipient), then you could simply add a “read” column to the table you store the messages in – but it’s better design-wise to use a separate table.

    # November 1, 2012 at 12:51 am

    are u mean I will make column “read” with two value 0,1
    0-> unread & 1->read
    and if the reader get page will be turn from 0 to 1 ??

    like this

    $q = mysql_query(‘UPDATE messages SET read=’1′ WHERE m_id = ‘$id’ “) ;}

    # November 1, 2012 at 1:53 am

    right. note, however, that it is better from a database design standpoint to record this in a separate table, as in my first example.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".