KyleMassacre Posted January 31, 2012 Share Posted January 31, 2012 Ive been looking around for a mailbox mod that if a user goes to delete the message it doesnt delete it from the db just hides it from there mailbox so only i can delete the messages after i decide if i want to read all of them or not any help would be great Quote Link to comment Share on other sites More sharing options...
prototype Posted January 31, 2012 Share Posted January 31, 2012 its simply run this query ALTER TABLE `mail` ADD `hide` int(11) NOT NULL; Find $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC LIMIT 25"); and replace it with the following code in mailbox.php $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid AND m.hide='0' ORDER BY mail_time DESC LIMIT 25"); and than find $db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid"); replace it with the following code $db->query("UPDATE mail SET hide='1' WHERE mail_id={$_GET['ID']} AND mail_to=$userid"); hope it works Quote Link to comment Share on other sites More sharing options...
Nickson Posted January 31, 2012 Share Posted January 31, 2012 Yea or he could simply create another table and just have it insert into both and only delete from 1 O.o Why the "h" would you do that for? No point in doing such thing. The technique prototype suggests is a whole lot better. You run less queries, you only keep the data once. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 31, 2012 Author Share Posted January 31, 2012 Yeah, I think ill stick to prototypes way. Adding another table is just too much for me just to keep duplicate info but thanks everyone for your help now I can bust those sneaky, pesky people advertising or bartering from one game to another Quote Link to comment Share on other sites More sharing options...
sniko Posted January 31, 2012 Share Posted January 31, 2012 Why not create a new table, and archive the deleted mails to that new table? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 31, 2012 Author Share Posted January 31, 2012 its simply run this query ALTER TABLE `mail` ADD `hide` int(11) NOT NULL; Find $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC LIMIT 25"); and replace it with the following code in mailbox.php $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid AND m.hide='0' ORDER BY mail_time DESC LIMIT 25"); and than find $db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid"); replace it with the following code $db->query("UPDATE mail SET hide='1' WHERE mail_id={$_GET['ID']} AND mail_to=$userid"); hope it works Well, i got no errors which was great so thumbs up for that one but its not hiding them in the inbox The words `data normalization` spring to mind. Duplicating data is normally a bad idea. A `deleted` field containing the timestamp (or datetime) the record was flagged as being deleted is about the only difference I'd suggest; that or shrink your data type to a boolean (tinyint(1)) if you insist on using `hide`. That would sound good if I had any idea what your talking about lol. Im a huge n00b so what your saying to me sounds like wookie. Im still trying to learn as much as i can but i still have trouble with the SQL and all te terminology of it sorry!!! Quote Link to comment Share on other sites More sharing options...
sniko Posted January 31, 2012 Share Posted January 31, 2012 I see, thanks for pointing that out Octarine. Just a question - kind off a tangent from the topic - but, when you would you advise 'archiving' then? Quote Link to comment Share on other sites More sharing options...
sniko Posted February 1, 2012 Share Posted February 1, 2012 Ah yes, Thank you Octarine! Quote Link to comment 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.