| Dan Shirah 2007-03-16, 6:58 pm |
| Try something like this:
****Your query here to get your dropdown values****
**
*// This first option value will set your default dropdown to display as
blank*
echo "<OPTION value=\"\">--SELECT--</OPTION>\n";
*// This will create a loop to return each option of your dropdown*
foreach ($query_result as $q)
{
*// This if statement says that IF the value in your database matches your
$_POST(selected) value then mark it as SELECTED*
if ($q['my_column_value'] == $_POST['my_selected_value'])
echo "<OPTION value=\"{$q['my_column_value']}\"
SELECTED>{$q['my_column_value']}</OPTION>\n";
*// This else statement will return your default(unselected) dropdown list
if it can't match the selected value with a value in your database*
else
echo "<OPTION
value=\"{$q['my_column_value']}\">{$q['my_column_value']}</OPTION>\n";
}
Hope that helps.
On 3/16/07, Onochie Anyanetu <ubernoch@gmail.com> wrote:
>
> Almost what I wanted to do.
>
> I am looking for a way to set the default option value to the selection
> the
> user just chose. for example, something like
>
> <select name=cars value=$_POST['cars']>
>
>
> On 3/16/07, Gunawan Wibisono <landavia81@gmail.com> wrote:
> means
> like:
> to
> and
> the
> u
> but
> statement
> retrieved
> submit
> (using
> was
> disabling
> no
> i
> global
> out
> the
>
|