Jump to content

[SOLVED] keep track of message sender


Dragen

Recommended Posts

Hi,

I'm writing a messaging system for an online shop where users can contact merchants and vice-versa.

Now I'm fine with writing the form, databases etc I've just got a question on how best to do something.

 

In the code I need to check whether the sender/recipient is a normal user or a merchant, so it can get the user information from the correct table (one for merchants, another for users). This is mainly for display replies, so it can show who it was from. At the moment I'm getting the sender's account type when they send a message and storing it along with the message as it's the only way I can think of doing it.

 

Does anyone else have any ideas? I mean on websites when you send a support ticket, how do they keep track of whether replies are from the user or the support personnel (I'm assuming they won't be stored in the same table)?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/
Share on other sites

they are stored in the same table. there is one table with a flag to indicate whether the record is a user or support personnel. thus, a single identifier points to a single person, instead of having to also use a second variable (table identifier). you should try to avoid duplicating data as much as possible (i.e., normalize your database.)

yeah, fair enough.

The reason I'm using separate tables though is because the accounts work completely differently with lots of variations in the tables themselves, so having them as one table wouldn't make it easier.

I may look into merging the two tables an decide on which method to use.

there are probably similar fields between the 2 types of people (first name, last name, phone number, email address). so you could create one table for 'people', then link them via record id to different tables depending on what type of people they are, like 'user_information' and 'support_information'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.