kasitzboym Posted June 14, 2010 Share Posted June 14, 2010 Hi everyone... I have kind of a complicated problem that i hope someone can help me with. I have a registration section of my site already up and running... i am trying to create another section of my site so that the user that is logged in can create a posting and link it to their username.... currently i have two tables in a mysql database one named (users) to hold the username and password that i want to pull the username from and another that holds the information for posting called (laf).... My basic question is how can i pull the username from the (users) database and place it into the (laf) database when they post? This is a really hard thing to explain i know, if anyone can help or needs any more information let me know... Thanks in advance Link to comment https://forums.phpfreaks.com/topic/204690-data-information-from-one-table-to-another/ Share on other sites More sharing options...
Rustywolf Posted June 14, 2010 Share Posted June 14, 2010 if you set the username as $_SESSION['user'] then you could use something like this: mysql_query("INSERT INTO laf (username, data) VALUES('" . $_SESSION['user'] . "', '" . $data. "'); then list like: mysql_query("SELECT * FROM laf WHERE username='" . $username . "'"); Link to comment https://forums.phpfreaks.com/topic/204690-data-information-from-one-table-to-another/#findComment-1071659 Share on other sites More sharing options...
kasitzboym Posted June 14, 2010 Author Share Posted June 14, 2010 Sorry i dont quite understand... This is getting a little more advanced than im used to do you think you might be able to explain it a little to me please? Link to comment https://forums.phpfreaks.com/topic/204690-data-information-from-one-table-to-another/#findComment-1071662 Share on other sites More sharing options...
isedeasy Posted June 14, 2010 Share Posted June 14, 2010 edit - meh I read the question wrong... When the user logs in you need to set a session variable containing their id/username. you can then use this value in your mysql where clause. Link to comment https://forums.phpfreaks.com/topic/204690-data-information-from-one-table-to-another/#findComment-1071666 Share on other sites More sharing options...
kasitzboym Posted June 14, 2010 Author Share Posted June 14, 2010 Thanks for the advice... Ive looked over the Session commands but dont quite understand how they work... could someone help me to understand how to pull that username from the current session Link to comment https://forums.phpfreaks.com/topic/204690-data-information-from-one-table-to-another/#findComment-1071704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.