Re: building forms from what the MySQL table looks like
| From: | David Robley | Date: | Mon, 18 Mar 2002 10:04:12 +0000 |
| Subject: | Re: building forms from what the MySQL table looks like | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88902@lists.php.net to get a copy of this message | ||
In article <3C95B597.3BB0B1B2@indent.com.au>, justin@indent.com.au
says...
> Hi,
>
> I've been thinking about this for a while, and I think I'd get a lot of
> value out of a library which builds user-input forms from scratch, based
> on the MySQL table.
>
> If I had a simple table for a CD catalogue:
>
> id (INT 4)
> artist_id (INT 4)
> description (MEDIUM TEXT)
> price (VARCHAR 7)
>
>
> Then I'd love to be able to build a form for entry of each new CD, based
> on the column names and types in the above table:
>
> <FORM action="blah.php" action="post">
> <B>artist_id</B>: <INPUT type="text" name="artist_id"
> value=""
> length="4" maxlength="4"><BR>
> <B>description</B>: <TEXTAREA name="description" rows="5"
> cols="40"><BR>
> <B>price</B>: <INPUT type="text" name="price"
> value="" length="7" maxlength="7"><BR>
> <INPUT type="submit" name="submit" value="submit">
> </FORM>
>
>
> So, my question is, how do efficiently establish the data type, length
> and name of each field.
>
>
> The rest, I think I can handle :)
>
>
>
> Thanks in advance,
>
> Justin French
>
Have a look at mysql_field_type() from which you should be able to build
something along the lines of what you want. You might also peer into the
innards of phpMyAdmin, which does the same sort of thing.
Cheers
--
David Robley
Temporary Kiwi!
Quod subigo farinam