Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting and sending info into/from MYSQL Tables (advanced)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm making a small built in mail system for my co-workers. I have decided to have one main table where all the usernames and passwords are stored. Everytime I add a user I've made mysql make a table with the user's name. That table is his or hers inbox.
This is where I'm stuck. Pretend there are two users: Katy and Ted. When Katie sends a message to Ted, data needs to be put in ted's table, right? The form stores ted's name as $senttouser. Now first I need to know how you can send the data to a table with the same value of $senttouser.
Um...my company has said it wants it working like this so please may I not have any suggestions of having a message table.
 
I guess you could just put the $senttouser as the table name, like this (assuming you are using PHP)
Code:
if (mysql_query("INSERT INTO $senttouser VALUES (your values)") === FALSE)
    die("That user doesn't exist.");
The "That user doesn't exist." should be inserted once you know that your query should work. //Daniel
 
Whatever values should be inserted into the table. First, what does each users table look like? Secondly, how does one send messages to another? Is it through a form? What does the form look like? //Daniel
 
Each users table has an id for number, title, message and who it is sent from. Yes its sent thru a form with the above.....
 
Well, then the query might look like this:
Code:
if (mysql_query("INSERT INTO $senttouser VALUES (NULL, '$title', '$message', '$sentfromuser')") === FALSE)
    die("That user doesn't exist.");
else
    echo "Your message has been sent.";
Change the variables' names to those that your form has. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top