#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2015
    Location
    Philippines
    Posts
    71
    Rep Power
    3

    Post PHP MySQL Messaging System with multiple recipient


    I'm currently working on a website that has messaging system. I already created it's simple profile but now
    I'm wondering how I will make a message with multiple recipient. I'm using PDO here

    I constructed this database table with id, subject, to, content, stamp where id is auto-increment

    I believe that there is a kind of structure where I will array the recipients ID to the column like
    Code:
    to: 1,2,3,4,5,6
    where message will be sent to users 1 to 6. But here, how can I
    read the table column data with comma? I heard explore or implode can be used in this.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,279
    Rep Power
    9645
    Don't do that.

    Have two separate tables, one for the message content (and sender?) and one for the recipients. The second table has one row per message ID + recipient ID, so a message with 6 recipients will have 6 rows in that table.

    Comments on this post

    • MonP agrees
    • antjciulla agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2015
    Location
    Philippines
    Posts
    71
    Rep Power
    3
    Originally Posted by requinix
    Don't do that.

    Have two separate tables, one for the message content (and sender?) and one for the recipients. The second table has one row per message ID + recipient ID, so a message with 6 recipients will have 6 rows in that table.
    Thank you for that great idea! I'll use it on my system.

IMN logo majestic logo threadwatch logo seochat tools logo