Re: Highlighting a stored value as 'selected'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jarratt,

Thank you for your advice. I will try that and come back with the result.

Alp

"RaTT" <shaggie@xxxxxxxxx> wrote in message
news:61f5e49905020802347d67bb4b@xxxxxxxxxxxxxxxxx
> Hello Alp
>
> Try something like,
>
> <?php
>
> //DB fields as an array
>
> $db_fields = array('left' => 'left',
>    'center'   => 'center',
>    'right' => 'right');
>
> function drop($array,$sel_name='',$sel_field='',$css=''){
> $dropdown = "<select name=\"$sel_name\" $css>\n";
> foreach($arr as $key => $val){
> $sel = ($sel_field == $key)?' selected="selected"':'';
> $dropdown .= "\t".'<option
value="'.$key.'"'.$sel.'>'.$val.'</option>'."\n";
> }
> $dropdown .= "</select>\n";
> return $dropdown;
> }
> usage:
> echo drop($db_fields,'test_select','center');
> ?>
>
> HTH
> Jarratt
>
>
>
> On Tue, 8 Feb 2005 17:14:24 +0800, Alp <alp.bekisoglu@xxxxxxxxxxxxxx>
wrote:
> > Is there an easier way to display/highlight the value stored in the
database
> > for a select option? Such as:
> > Stored value is 'center'. The statement is:
> > print '<select name="colalign">';
> > print '<option value="left">Left';
> > print '<option value="center">Center';
> > print '<option value="right">Right';
> > print '</select>';
> >
> > I can have 3 sets of the above tied to 'if's but would rather ask for an
> > easier or better way.
> >
> > Thanks in advance.
> >
> > Alp
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux