Messaging
Moderator: General Moderators
Messaging
Hello, I am trying to think up a way of messaging users..
I have a db named "tradeacc" and the fields Username, and password.. Now I was thinking maybe everytime you try and send a message it will create a new field.. as subject then sub- message..date etc
but how do I go about making a sub field?
please help!
I have a db named "tradeacc" and the fields Username, and password.. Now I was thinking maybe everytime you try and send a message it will create a new field.. as subject then sub- message..date etc
but how do I go about making a sub field?
please help!
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
if its private messaging (like these forums its incredibly easy and was actually teh first major app i built
Mysql DB private_messaging
receiver
sender
message
date
status
this will get the messages that are for the user currently logged in, i used status to check if it had been read before or not
this should be a good starting point for you........
good luck
Mysql DB private_messaging
receiver
sender
message
date
status
Code: Select all
// pseudo code
$query = "SELECT * FROM private_messaging WHERE receiver = '$_SESSION[username]' ORDER BY DATE asc";
$result = mysql_query($query) or die(mysql_error())
$array = mysql_fetch_array($result, MYSQL_ASSOC);this should be a good starting point for you........
good luck
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Code: Select all
ALTER TABLE `table_name` ADD `new_field` VARCHAR(255) DEFAULT 'test';-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Ugh I am new to all of this so pelase easy!
lol I have user accounts.. and I want it to add the field on the line with the pecific username.
like
Nick | password | info1 | info2 | added message1
can you maybe tell me if this is rigth as well?
thanks!
lol I have user accounts.. and I want it to add the field on the line with the pecific username.
like
Nick | password | info1 | info2 | added message1
can you maybe tell me if this is rigth as well?
thanks!
Code: Select all
<?php
if ((!$_POSTїMsgU]) || (!$_POSTїsubject]) || (!$_POSTїMsg])) {
header ( "Location: Http://www.pixelfriendly.com/tradesys/sendmsg");
exit;
}
#variables#
$db_address = "localhost";
$db_name = "pixelfriendly_com";
$table_name = "tradeacc";
$db_user = "pixel";
$db_pass = "****";
#connection#
$connection = @mysql_connect($db_address, $db_user, $db_pass) or die(mysql_error());
#select db#
mysql_select_db($db_name) or die(mysql_error());
#create table#
$sql = "ALTER TABLE `tradeacc` ADD `$_POSTїsubject]` VARCHAR(255) DEFAULT '$_POSTїMsg]' & '|' & 'From:user' & 'Date send''";
#results#
$result = @mysql_query($sql, $connection) or die(mysql_error());
#sent#
echo " sent! ";
?>Just making sure before making comment...nick2 wrote:thansk kettle.. can you give me an example on how to create a new field with code? thanks
Are you really interested in creating a new type of field in the database, rather than adding information to the existing database?
... just doesn't look correct.Code: Select all
$sql = "ALTER TABLE `tradeacc` ADD `$_POSTїsubject]` VARCHAR(255) DEFAULT '$_POSTїMsg]' & '|' & 'From:user' & 'Date send''";