Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a table of usernames and passwords and other details, how can I add a table that stores messages left by other users which the user can read and reply to?

To answer your specific question:
1) create a table to store messages in
2) write one or more programs for
a) users to leave messages
b) users to read and reply to their messages
I suspect (hope) that the question that you meant to ask is much more specific, ie. How do I create a table with these fields? How do I read a mysql table from a PHP program? etc.Good luck

I know how to get data and post data to a database using SQL. Is it as simple as having a primary ket for example, userId in both tables and messages in the message table would relate to that user?

"Is it as simple as having a primary ket for example, userId in both tables and messages in the message table would relate to that user?"
Basically, yes.
I would suggest something like:
USER TABLE:
userId integer primary key
- along with whatever other user info you want, like name, login/password, etcMESSAGE INFO TABLE:
messageId integer primary key
toUserId integer (id of user the msg is TO)
fromUserId integer (id of user the msg is FROM)
- you'll probably want to have another index on the toUserId field
- there's plenty of other info that you might keep, ie receivedDateTime, hasItBeenRepliedTo, etcMESSAGE TABLE:
messageId integer primary key
messageText large character fieldFor each message, you'd insert one record into each of the two message tables. For the MessageInfo table, you'd create a unique messageId and use the User IDs of the user sending the message and the user receiving the message. Then you'd insert that messageId, along with the message text into the Message table.
The MessageInfo and Message table could be one table rather than two. Two advantages of using two tables:
1) if you query the messageInfo table, you can look at the details (userIds, any other info you might add) without having to scroll thru the text of the message, which can be a pain if the text is large (1000+ chars?)
2) if a given message is meant for more than one user, you insert multiple records into the MessageInfo table but have only one copy of the message text in the Message table.
But, if you aren't worried about one message to multiple users, you could combine the two message tables.

![]() |
Creating textfiles in ASP
|
Javascript, div, visibili...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |