Re: dynamic form help
| From: | Jon Rosenberg | Date: | Wed, 22 Nov 2000 20:51:07 +0000 |
| Subject: | Re: dynamic form help | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26704@lists.php.net to get a copy of this message | ||
Thanks for that bit of help...but, is there any way to do it where I don't
have the list of options stored in the db? I can add them to the db, but
I'd rather not since I have so many form fields to do. Thanks!!!
----- Original Message -----
From: "Cristian Donoso" <cdonoso@woc.cl>
To: "Jon Rosenberg" <php@columbusinteractive.com>; "PHP List"
<php-general@lists.php.net>
Sent: Wednesday, November 22, 2000 3:27 AM
Subject: RE: [PHP] dynamic form help
> > What would be the best way to do the following? I have a mysql db
record,
> I
> > have it so people can login against the db and now I want to allow them
to
> > edit the information about them in the db. The form they create their
> entry
> > with is a combination of text boxes and drop-down selection menus. When
> > they log in I want the form that comes up to have the values in it that
> they
> > originally signed up with. I know how to populate the text box fields
> > dynamicly with value=$var_name , but how can I make it so that the
> selection
> > drop-down menus have what they selected? I essentially need to be able
to
> > write those parts of the form like this:
> >
> > drop-down:
> >
> > You have 3 choices, your current selection is...you can change it if
you'd
> > like and save it to the db:
> > <SELECT>
> > <OPTION>1</OPTION>
> > <OPTION selected>2</OPTION>
> > <OPTION>3</OPTION>
> > </SELECT>
> >
> > how can I make it so that the 'selected' appears in the right place?
and
> > yet still include all the other options so they can change it if they
want
> > to?
>
> If you have stored in your DB the option, you can do something like this:
>
> print "<SELECT>";
> for ($i=1 ; $i<=3; $i++) {
> ($i == $value_from_database) ? $sel = "selected" : $sel = "";
> print "<OPTION $sel>$i</OPTION>";
> }
> print "</SELECT>";
>
> this only works if the $value_from_database is an INTEGER but that's the
> idea.
>
> ______________________________
> Cristian Donoso Monteiro
> Temuco - Chile
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>