arjang Posted June 20, 2011 Share Posted June 20, 2011 Hi guys:) i have two tables in my mysql db, english_articles and persian_articles. i want to be able to insert data into each table using only one from with dropdown menu for table names. for example, if i select persian_articles, data should go to persian_articles table and vice versa. i would really appreciate if you helped me solve my problem and give me a code for it. i am new to php and mysql so please dnt be too technical. Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/ Share on other sites More sharing options...
YoungNate_Black_coder Posted June 20, 2011 Share Posted June 20, 2011 give me the code u have and be a little more specific ! Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/#findComment-1232087 Share on other sites More sharing options...
arjang Posted June 20, 2011 Author Share Posted June 20, 2011 i attached the code. this code only inserts data into english_articles. i want to give the option to the user to choose between any of the two table to insert data into. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/#findComment-1232136 Share on other sites More sharing options...
TeNDoLLA Posted June 20, 2011 Share Posted June 20, 2011 Something like this? <?php if (isset($_POST['table'])) { if (intval($_POST['table']) === 1) { // Insert data into english table } else if (intval($_POST['table']) === 2) { // Insert data into persian table } else { // Error selecting table. } } ?> <html> <head> <body> <form action="test.php" method="POST"> <select name="table"> <option value="1">english</option> <option value="2">persian</option> </select> </form> </body> </head> </html> Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/#findComment-1232141 Share on other sites More sharing options...
arjang Posted June 20, 2011 Author Share Posted June 20, 2011 thanx alot guys:) i give it a try. hope i get how it works. thanx again for helping:) Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/#findComment-1232196 Share on other sites More sharing options...
arjang Posted June 20, 2011 Author Share Posted June 20, 2011 thank you for the code:) it solved my problem:) Link to comment https://forums.phpfreaks.com/topic/239859-help-with-inserting-data-to-multiple-mysql-table-based-on-user-selection/#findComment-1232242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.