MySQL query and PHP

Discussion in 'PHP' started by karl_murphy, Mar 20, 2008.

  1. #1
    I am trying to develop a simple messaging system. I have already developed the relevant sections to be able to send and recieve messages, but I am have trouble creating the "Sent items" area. Basically this section will allow the user to view the messages they have sent.

    I have set up three tables to facilitate the messaging system and they are as follows:

    Mail

    MA_ID
    MA_Subject
    MA_Message
    MA_Date

    Mail_Inbox

    MI_MA_ID
    MI_Recipient

    Mail_Sent

    MS_MA_ID
    MS_Sender


    If you can imagine user A sending a couple of messages to two other users. This is how the tables are populated:

    Mail

    MA_ID- - - MA_Subject- - -MA_Message- - -MA_Date
    1 - - - - - - - Subject A - - - - Message A - - - - 01/01/2008
    2 - - - - - - - Subject B - - - - Message B - - - - 02/01/2008


    Mail_Inbox

    MI_MA_ID - - - MI_Recipient
    1 - - - - - - - - - - - - B
    1 - - - - - - - - - - - - C
    2 - - - - - - - - - - - - B
    2 - - - - - - - - - - - - C


    Mail_Sent

    MS_MA_ID - - - MS_Sender
    1 - - - - - - - - - - - - A
    2 - - - - - - - - - - - - A


    I want to set up an area where a user can view the messages they have sent. For this example, if user A logged in and wanted to see the messages they had sent, I would want it to look something like the following:

    To - - - Date - - - Subject
    B, C - - 01/01/2008 - - Subject A
    B, C - - 02/01/2008 - - Subject B

    I'm having problems writing a query to extract this data aswel problems writing code to display it in this way.

    Any ideas?
     
    karl_murphy, Mar 20, 2008 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    Do you mean you want the database to store which member/user sends an email and to which other member/user they sent it to ?

    I dont think you specified that , but Im assuming youre giving your users a 'A,B,C' etc represenatation.

    What you're building looks like a site mail spying or snoop system lol


    Maybe you should look into PHP.net join function
    Finding it hard to help you ..since i suspect that could be a snooping system on your sites user emails.
    That would be a crappy thing to do if thats what its for.
    Unless its for some security place that has to track all emails coming and going and to which peoples they are sending to. Because thats a real transparent email system youre trying to create. a big glass two-way mirror looking in at all mail coming and going. lol
     
    ezprint2008, Mar 20, 2008 IP