on 4/26/02 4:39 AM, its me at [EMAIL PROTECTED] appended the following bits to
my mbox:

> in it i have a form field like this:
> <select name="location">
>              <OPTION selected value="">Choose City</OPTION> <OPTION
>                     value=10-Ramadan>10-Ramadan</OPTION> <OPTION
>                     value="15 May">15 May</OPTION> <OPTION
>                     value=6-October>6-October</OPTION> <OPTION
>                     value="Abou Redes">Abou Redes</OPTION> <OPTION

> and i got from my database:
> $location="Alexandria"
> so i wanted to appear selected,how can i do this??

Easy solution:

Get rid of the word "selected" in the first option.  The browser will
default to the first anyway.

After the <select> tag, echo:

echo '<option value="' , $location , '">' , $location , '</option>';

That will list the selected item as the first item in the list.

Hard solution:

Go thorough the list and put:

<?php if ($location == 'Alexandria") { echo ' selected'; } ?>

In each of your option tags. (ouch).

Less hard solution:

Put all of the options into an array and then create the list by looping
through the array, each time checking the value to see if it is the selected
one using the code above.



Paul Burney

    while ($self != "asleep") {

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to