Print the current value as the first entry of the pulldown.
It will be in the pulldown twice, but so what?
Nelson Goforth wrote:
> I have a Contact information page that draws from or writes to a table
> [contact] and displays that information in an HTML form. There is a
> field [type] that I want to have populated from a pulldown list, and
> that pulldown list is drawn from another table [contact_type]. I'm using
> PHP 3.x for the interface (hopefully my remote server will upgrade
> sometime soon).
>
> For creating a new record, no problem - but if the form is displaying
> data from an existing record, I want the pulldown list to indicate the
> existing value for 'type'. I've done a brute-force 'if-then' version of
> this for a two value radio button, but doing a list like that could get
> ugly. I'm hoping that someone has a more elegant solution.
>
> Here's the code I'm using - the pulldown displays nicely.
>
> $list = mysql_query("SELECT id, type FROM contact_type, $link);
>
> printf("<TR><TD CLASS=\"FormItem\">Contact Type: </TD>");
>
> printf("<TD CLASS=\"FormInput\"><SELECT NAME=toolnum>");
> while ($row = mysql_fetch_object ($list)) {
> printf("<OPTION VALUE=%s>%s</OPTION>", $row->id, $row->type);
> }
> printf("</SELECT>%s</TD></TR>\n", ($formValues) ? $formValues["id"] :
> "");
>
>
> That last line is something I'm using to display text input values, but
> of course it doesn't work here except to give the id number of the
> contact type.
>
> Any notions on this topic? I could use a hard-coded pulldown list, but
> I want to have the flexibility to create new values, and also to have
> the values display in a foreign language if desired.
>
> Thank you for any help.
> Nelson
--
Gerald L. Clark
[EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php