On Fri, 2008-04-25 at 17:32 -0500, Jay Blanchard wrote: > [snip] > I can't say I've ever had a form that exactly matched a database table > for a user perspective. From an admin perspective that changes, but that > was when I downloaded PHPMyAdmin for the client. It was amazing, every > form matched the database table and you could view all the rows too, and > even create your own queries. > > Table discovery is something I use for marshalling data back and forth > from database tables, but not usually for presenting a user form. > [/snip] > > That is why there is code to exclude columns from the form and > essentially the group of functions pretty much does what phpmyadmin > does. Handling multiple tables in one form of course is a different > story. > Actually it's quite easy. I've got a similar object to the one you guys described (can't really share it - I'm on salary so technically it belongs to my boss.) Anyhow when I do my table layout, if there's a look-up, I name the field "lookuptable_id" in the DB. In my object, it looks for any field ending in "_id" (or whatever you specify to the object - "_id" is just the default) and it creates a drop-down of the options. The object also takes an array of ignore_fields, hidden_fields (good for ID's on updates), friendlynames (you don't always want to use the fieldname in the database, but anyhow the object replaces underscores and capitalises), and a bunch of other customising array properties with useful defaults. It also detects whether this is an insert or update and knows how to route the action, and has support for file uploads (and customises the enctype of the form for that). So basically you can have a very nice form, customised, with one or two lines of code to draw the form, as long as you design your object and DB well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php