nphilipe Posted May 24, 2012 Share Posted May 24, 2012 Hey guys!can someone please help me with this code...am trying to insert some data into the database and apparently, the field name for the data to be inserted into is among the list button selections.ie the list button selections are the corresponding sql fieldnames.i want whatever is entered into the links field to be inserted into the selected table in the dropdown list.is this possible? Here is the code: 18443_.php Quote Link to comment https://forums.phpfreaks.com/topic/263041-inserting-data-into-the-database-using-an-option-from-a-list-button/ Share on other sites More sharing options...
DanWhite Posted May 27, 2012 Share Posted May 27, 2012 If I understand your question correctly, $rowname = $_POST["category"]; $inserted_stuff = $_POST["link"]; /* For col name- */ mysql_query("INSERT INTO table ($rowname)VALUES('$inserted_stuff')); /* Or for table name */ mysql_query("INSERT INTO $rowname (colname)VALUES('$inserted_stuff')); --- Dan White UK based PHP developer & web designer. http://Dans-Media.com Quote Link to comment https://forums.phpfreaks.com/topic/263041-inserting-data-into-the-database-using-an-option-from-a-list-button/#findComment-1348869 Share on other sites More sharing options...
nphilipe Posted May 27, 2012 Author Share Posted May 27, 2012 stupid me. it worked. am just starting out with my site and that bit got me confused abit. thnks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/263041-inserting-data-into-the-database-using-an-option-from-a-list-button/#findComment-1348920 Share on other sites More sharing options...
DanWhite Posted May 27, 2012 Share Posted May 27, 2012 No problem. Let me know if I can help any further! Quote Link to comment https://forums.phpfreaks.com/topic/263041-inserting-data-into-the-database-using-an-option-from-a-list-button/#findComment-1348923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.