graham23s Posted May 17, 2007 Share Posted May 17, 2007 Hi Guys, just a question i have in regards to a private messaging system for asite, i have done a few, but i always do 2 tables: private_messages private_messages_sent but on a scripts i downloaded in the mysql schematics there was only 1 table: messages with: CREATE TABLE `messages` ( `id` int(10) unsigned NOT NULL auto_increment, `sender` int(10) unsigned NOT NULL default '0', `receiver` int(10) unsigned NOT NULL default '0', `added` datetime default NULL, `msg` text, `unread` enum('yes','no') NOT NULL default 'yes', `poster` bigint(20) unsigned NOT NULL default '0', `location` enum('in','out','both') NOT NULL default 'in', so i could have gotten away with doing just 1 table instead of the 2, or is it better the way i was doing it (probably not lol) cheers guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/51878-solved-private-message-system-question/ Share on other sites More sharing options...
pocobueno1388 Posted May 17, 2007 Share Posted May 17, 2007 Well...you don't really need another table to be able to tell the user what messages they have sent. Just do a query that will pull the messages they have sent by matching their ID with the "sender" field. <?php $sql = mysql_query("SELECT * FROM messages WHERE sender='$user_id'"); echo 'You have sent the following messages...<p>'; while ($row = mysql_fetch_assoc($sql)){ echo $row['message'].'<br>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51878-solved-private-message-system-question/#findComment-255690 Share on other sites More sharing options...
graham23s Posted May 17, 2007 Author Share Posted May 17, 2007 That's true, thanks mate:) Graham Quote Link to comment https://forums.phpfreaks.com/topic/51878-solved-private-message-system-question/#findComment-255747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.