FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Dynamic form generation
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Dynamic form generation [message #177645 is a reply to message #177642] Thu, 12 April 2012 04:46 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
Charles wrote:
> I'm working on a database application, and I'd like to write a function that takes the table structure from a MySQL database table and generates a fresh data entry form from it each time someone browses to it.
>
> That way I can have four functions that serve the four purposes of data entry, view/query, edit, and delete, instead of 4 scripts for each table (the application has 64 tables so far) that have to be editted every time the table changes.
>
> Is it possible to use PHP to generate data entry forms on the fly?

it certainly is, yes, but a general purpose function is less easy.

Because you need to associate e.g. a label for each entry box with a
field in each table.

And you may want to vary the layout for each presentable form.

My way of doing it to start what will probably be a long and acrimonious
religious discussion is to write a form library which does basic things
like putting and input box with a legend by its size at a given screen
location. Plus open and close database functions. And generic stuff goes
in there, plus a generic page header that sets up stuff like the overall
screen appearance and style sheets and any menu systems that you might
have. That code is common to all screens.

Then each form is custom written forte tables uit access. In genarl it
has these parts.

1/. Set up the page headers and any menu systems by calling a generic
initialisation with the page identities as the parameters to pass. Also
open the database.

2/. If the form has been called as a result of a submit operation check
for that and if so check as to whether (usually) some row ID is set -
if it is you can regard that as an update, and parse and valisdate and
sanitise the PUT variables before updating the database (or returning
some error).

3/. else if its an update but no ID is set assume its new data to be
interested. How you arrange to do that depends on how you want the form
to work. Insert te data, bick up the last insret id and copy that into
your gobal id field.

4/ then draw the screen either with empty data or by reloading the data
from the DB using the global record ID variable as the key.

Thats what works for me.



>
> Does anyone have any recommendation for a reference resource or some sample code to study for this?
>


--
To people who know nothing, anything is possible.
To people who know too much, it is a sad fact
that they know how little is really possible -
and how hard it is to achieve it.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Data injection problems
Next Topic: Do you want to develop PHP for the Web and make money
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 01:11:37 GMT 2024

Total time taken to generate the page: 0.04867 seconds