|
|
|
|
![]() ![]() |
Feb 16 2008, 10:34 PM
Post
#1
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
Hey! I just wanted to know, if I want to make a PM system, should I store the PMs in a database or how should I do it? And if I should store them in a database, how do I do that. Because I have acctually no idea, if I should create 50 tables to store 50 messages
(And a little OT question[instead of creating a new topic]). How can i change the timestamp [time()] into real date? This post has been edited by Feelay: Feb 16 2008, 10:39 PM |
|
|
|
Feb 17 2008, 03:30 AM
Post
#2
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
In short, yes!
You would save PM's in the database... You create a table in your database with at least 4 columns (fields) then each message gets its own row (record). I suggest the following columns: message_id user_id_from user_id_to message_title message_contents message_date message_read The first is the id of the message which should be incremented in MySQL each message. (1,2,3,...) The second is the user id (username, id number, whatever) of the sender of the message. The third is the user id (username, id number, whatever) of the recipient of the message. The forth is the title of the message. The fifth is the actual contents of the message. (message body) Sixth is the date which the message was sent. Finally, seventh is a flag as to whether or not the message has been read. (Yes | No) OR (1 | 0) The system is actually very simple to code and I have confidence that you will be able to do it. I wouldn't try doing a filing system for PM's and when a user deletes a message, then remove it from the database. The new message alert would just be a database query to find any messages with the user's ID being the same as the user_id_to and that hasn't been marked as read. Now for your time issue... The PHP manual does a very good job of explaining how to use time and date functions. Here is the link: http://us.php.net/manual/en/function.date.php One thing to consider, if you are using a UNIX timestamp (seconds since 1/1/1970) then you enter that as the second argument of the data function like so: CODE echo date("F j, Y, g:i a", 3600); // January 1, 1970, 1:00 am Because, 3600 seconds is 1 hour from the Epoch (1/1/1970)! Likewise, this is what you would use for the date of January 5, 1970 at 2:34 pm: CODE echo date("F j, Y, g:i a", 484440); // January 5, 1970, 2:34 pm Because, 484440 seconds is 5 days 14 hours and 34 minutes from the Epoch! There are many formate examples on the page I linked to as well as a complete listing of every date code you can use with the date function. Hope this helps. vujsa |
|
|
|
Feb 29 2008, 10:33 PM
Post
#3
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
Thanks alot Vujsa
Thanks again //Feelay This post has been edited by Feelay: Mar 2 2008, 10:54 AM |
|
|
|
May 12 2008, 02:16 PM
Post
#4
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
OK I AM A KID. BUT I OWN A SITE. BUT I KNOW ONLY HTML AND JAVA, NOT DATABASES. COULD ANYONE MAKE A TUTORIAL ON DATABASES? THE WORLD WILL LIKE IT.
How To Make A PM (Personal Message) System? I own a site. But I use form systems for it. Presently, I am only 13 years old. Http://www.Schoolclub.Googlepages.Com By the way, I first designed my site on notepad with HTML, but forgot about publishing. Then I moved to GPC. Someone please teach me of databases. I would greatly appreciate it. By the way. The searches do not provide sufficient explanations on databases! Thank you! -reply by Thauwa |
|
|
|
Jul 25 2008, 04:18 AM
Post
#5
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 15 Joined: 25-July 08 Member No.: 31,646 |
In short, yes! You would save PM's in the database... You create a table in your database with at least 4 columns (fields) then each message gets its own row (record). I suggest the following columns: message_id user_id_from user_id_to message_title message_contents message_date message_read The first is the id of the message which should be incremented in MySQL each message. (1,2,3,...) The second is the user id (username, id number, whatever) of the sender of the message. The third is the user id (username, id number, whatever) of the recipient of the message. The forth is the title of the message. The fifth is the actual contents of the message. (message body) Sixth is the date which the message was sent. Finally, seventh is a flag as to whether or not the message has been read. (Yes | No) OR (1 | 0) The system is actually very simple to code and I have confidence that you will be able to do it. I wouldn't try doing a filing system for PM's and when a user deletes a message, then remove it from the database. The new message alert would just be a database query to find any messages with the user's ID being the same as the user_id_to and that hasn't been marked as read. Now for your time issue... The PHP manual does a very good job of explaining how to use time and date functions. Here is the link: http://us.php.net/manual/en/function.date.php One thing to consider, if you are using a UNIX timestamp (seconds since 1/1/1970) then you enter that as the second argument of the data function like so: CODE echo date("F j, Y, g:i a", 3600); // January 1, 1970, 1:00 am Because, 3600 seconds is 1 hour from the Epoch (1/1/1970)! Likewise, this is what you would use for the date of January 5, 1970 at 2:34 pm: CODE echo date("F j, Y, g:i a", 484440); // January 5, 1970, 2:34 pm Because, 484440 seconds is 5 days 14 hours and 34 minutes from the Epoch! There are many formate examples on the page I linked to as well as a complete listing of every date code you can use with the date function. Hope this helps. vujsa sign me up and create a template for me with login scripts. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 13th October 2008 - 05:28 AM |