Frank100 Posted June 24, 2007 Share Posted June 24, 2007 Hi, is there a way in php to look up a mysql table and use the column headings as form field variables … meaning with this php program the entire table columns are displayed as form fields in the browser ? No need then to build the form by hand … in this consequence there could be a input type column and a width column which could be used to also automatically create the right types of fields for that particular mysql table … Regards, Frank hdu43hd Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 24, 2007 Share Posted June 24, 2007 Yes - "SHOW COLUMNS FROM `tablename`" this returns an array of info for each field. (if you rn it in phpmyadmin you'll see what I mean.) Quote Link to comment Share on other sites More sharing options...
Frank100 Posted June 25, 2007 Author Share Posted June 25, 2007 thx for your reply, do you have a code sample how to get this to work to create a table ? I've researched google but was not able to find any. Frank Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 25, 2007 Share Posted June 25, 2007 ??? This only works once the table has been created... to create a table you use "CREATE TABLE `tablename`...' followed by the field name, type, attributes, NULL or NOT NULL, default value, (key type)... all those bits are what SHOW COLUMNS get for you. So, use the result of your show query, loop through each record and each array returned by each record to fill in the info for you. If you want help then post an example of what you need, the table you are using to generate info (the one you run the show query on) and the table structure you expect it to create. Quote Link to comment Share on other sites More sharing options...
Frank100 Posted June 25, 2007 Author Share Posted June 25, 2007 Hi and thx for reply, yes, I'd need help with a code please, which would be a sample for me how the code is to achive to get a .htm where each field of the table is represented as an input field in the .htm. Also using the column names and using the widthand field_type infos from the mysql_table content to define the width of each html input_field and field_type. www.hfpz.net/support/php/auto_input_table/city_table_01.jpg www.hfpz.net/support/php/auto_input_table/city_table_01.sql Quote Link to comment 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.