jakebur01 Posted February 27, 2009 Share Posted February 27, 2009 The table was created based on the number of columns the text file had in it and they were generated based on that flat file. ie. col1, col2, col3, col4, etc. On page 2 I select which columns contain which like list, dealer, distributor and so on. INSERT INTO {$tablename} VALUES $part = $itemnum, $list = '{$row[$list]}', $dealer = '{$row[$dealer]}', $distributor = '{$row[$distributor]}', $sort = '{$row[$sort]}', $stdpack = '{$row[$stdpack]}' I am wanting to insert the list, dealer, distributor, sort, and stdpack values into the appropriate columns. As you can see, I have those columns stored in variables ($part, $list, $dealer, $sort, & $stdpack). How can I get this done and still take care of the columns I don't know about that are in the table? Quote Link to comment https://forums.phpfreaks.com/topic/147156-solved-inserting-without-knowing-the-table-structure/ Share on other sites More sharing options...
Mchl Posted February 27, 2009 Share Posted February 27, 2009 INSERT INTO table (columnname1, columnname2) VALUES (value1, value2) This will only insert into columns called 'colmnname1' and 'columnname2', even if there are more columns in the table. Quote Link to comment https://forums.phpfreaks.com/topic/147156-solved-inserting-without-knowing-the-table-structure/#findComment-772488 Share on other sites More sharing options...
jakebur01 Posted February 27, 2009 Author Share Posted February 27, 2009 I learn several new things every day in php. It is one of the only things I am halfway good at. Thank you so much! That finalized the script I have been working on all week. Quote Link to comment https://forums.phpfreaks.com/topic/147156-solved-inserting-without-knowing-the-table-structure/#findComment-772497 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.