Re: intercative selection menu
| From: | Stephen Rhodes | Date: | Fri, 21 Jun 2002 14:04:44 +0000 |
| Subject: | Re: intercative selection menu | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19953@lists.php.net to get a copy of this message | ||
You could have if statements for every option.
May be better if you have a for loop for some of the options -- SEE BELOW.
e.g
<TR><TD><B><?php echo("cell name")?>:</B></TD>
<TD><select name="cellname">
<?php
//Do some database stuff (connect, query, get result etc etc) to get
the value that is stored. Put the number into the variable $var
for ($i=1904;$i<1912;$i++)
{
printf("<option value='%s'",$i);
if ($var == $i)
printf(" selected");
printf("> %s</option>",$i);
}
printf("<option value='1916'");
if ($var == '1916')
printf(" selected");
printf("> 1916</option>");
printf("<option value='volta'");
if ($var == 'volta')
printf(" selected");
printf("> volta</option>");
printf("<option value='scatt11'");
if ($var == 'scatt11')
printf(" selected");
printf("> scatt11</option>");
?>
</select>
</TD></TR>
Cheers
Steve
"Walid Dib" <Walid.Dib@med.ge.com> wrote in message
news:6EDD9DC298BF9C48AC3EF66EA92596BC0463AF25@frbucmsx03medge...
> Hello, I need to get back the present value in the data base and to
> post(show) it in the menu of selection. somebody has an idea??
>
> Thank you in advance.
> <TR><TD><B><?php echo("cell name")?>:</B></TD>
> <TD><select name="cellname">
> <option value="1904" selected> 1904</option>
> <option value="1905"> 1905</option>
> <option value="1906"> 1906</option>
> <option value="1907"> 1907</option>
> <option value="1908"> 1908</option>
> <option value="1909"> 1909</option>
> <option value="1910"> 1910</option>
> <option value="1911"> 1911</option>
> <option value="1916"> 1916</option>
> <option value="volta"> volta</option>
> <option value="scatt11"> scatt11</option>
> </select>
> </TD></TR>