Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> How To Make A PM (Personal Message) System?, (Should I Store The Data In A Database?)
Feelay
post Feb 16 2008, 10:34 PM
Post #1


Kinda N00B
Group Icon

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 tongue.gif

(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
Go to the top of the page
 
+Quote Post
vujsa
post Feb 17 2008, 03:30 AM
Post #2


Absolute Newbie
Group Icon

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. cool.gif

vujsa
Go to the top of the page
 
+Quote Post
Feelay
post Feb 29 2008, 10:33 PM
Post #3


Kinda N00B
Group Icon

Group: Members
Posts: 230
Joined: 13-January 08
From: Sweden
Member No.: 27,579



Thanks alot Vujsa smile.gif ! Now I have made a version 0.1 PM script. I'll make a tutorial about it someday tongue.gif And as you said, it was very easy to make the script tongue.gif just took me 3 hours wink.gif

Thanks again //Feelay


This post has been edited by Feelay: Mar 2 2008, 10:54 AM
Go to the top of the page
 
+Quote Post
iGuest
post May 12 2008, 02:16 PM
Post #4


Newbie [ Level 1 ]
Group Icon

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
Go to the top of the page
 
+Quote Post
Mike gambino
post Jul 25 2008, 04:18 AM
Post #5


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 15
Joined: 25-July 08
Member No.: 31,646



QUOTE(vujsa @ Feb 16 2008, 11:30 PM) *
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. cool.gif

vujsa

sign me up and create a template for me with login scripts.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php, Sql Lite: Storing Session's Data?(1)
  2. Php Problem Error Message(9)
  3. In Php, How To Not Display Mysql Connection Error?(4)
  4. Displaying Data From Mysql?(2)
  5. Help With Multi Tier Mysql Application Over Net(6)
  6. Php/mysql Data Display(3)
  7. Possible To Do?(7)
  8. Need Help With A PHP - MySQL Registration Script(13)
  9. Coding A Private Message System(4)
  10. [PHP + MySQL] Encrypting Data(11)
  11. [php] Index.php?section=xx&pag=yy(6)
  12. Reading Data From Sessions(2)
  13. What Database Do You Use With PHP(5)
  14. Need Help With 2-Way Password Encryption(8)
  15. Storing Data Into Xml With A Php Form(2)
  1. Need An Alternative To $http_post_data For PHP4(5)
  2. Data Passing - Re An Assignment For School - Please Help :)(8)
  3. Send XML Data To PHP Page(0)
  4. How To Show Serial Nums In PHP Table For Contents Of MySQL DB(4)
  5. Proper Way To Grab User Data?(1)
  6. Retrieving Data And Displaying In Boxes(6)
  7. Sql Injection Prevention (passing Numerical Data Across Pages).(9)
  8. Five Common Php Database Problems(0)
  9. Getting Certain Parts Of A Record(17)
  10. How To Make A Value In The Database Raise Every Minute.(50)
  11. Letting Users Add Mysql Data With Php(1)
  12. Reading Xml Data(2)


 



- Lo-Fi Version Time is now: 13th October 2008 - 05:28 AM