Re: Dynamically generating PHP functions?
| From: | David Robley | Date: | Fri, 15 Sep 2000 06:53:27 +0000 |
| Subject: | Re: Dynamically generating PHP functions? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16916@lists.php.net to get a copy of this message | ||
On Fri, 15 Sep 2000, Joseph H Blythe wrote:
> Hey,
>
> I have written a script that dynamically generates a form from a given
> database and table that would be suitable, as a generic data input
> device for any mysql table.
>
> My problem is that when I have tried to write the script for the forms
> action i.e.:
>
> ...
> mysql("database","INSERT INTO table Values (
> '$field1',
> '$field2',
> '$field3',
> '$field4'
> )");
>
>
> I cannot figure out how to generate the above function dynamically so
> that that it has the correct number of fields for the given database
> table, does anyone know how one would go about writing php functions
> dynamically then executing them?
>
> I suppose it is much the same as the way php dynamically generates html,
> but I need it to do it on itself, if this makes any sense.
>
> Any help would be much appreciated.
>
> Joseph
You might find either of mysql_fetch_field or mysql_field_name useful for
getting the field names from a known table. Have a look also at the code
for phpMyAdmin which does this sort of thing. It might be the solution to
your problem and you can knock off for the weekend and watch the opening
of the Olympics :-)
http://phpwizard.net/projects/phpMyAdmin/
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA