If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Message system - user select

I have an SQL table with users' messages and here's what the values are:

id, uid, to, sent, msg, date

id, the unique ID with auto increment (and primary key)
uid, the ID of the user who is sending the message
to, the ID of the user who the message is to
msg, the message
date, the timestamp

The problem I'm having is trying to select the users who the user has sent or received messages from/to. I keep getting repeats or a user is missing. I had an idea of going through each user and going through validation to make sure that person isn't already there but it doesn't seem to work properly.

$id is from the session variable $_SESSION['id'] which is declared in an include file.