Re: HTML FORMS selected question

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

Mag Gam wrote:
I am having trouble getting values populated in my form... Here is what I got so far:

//The values that need to be selected

//This will show ALL values.
foreach ($options as $index => $option) {
    if ($rows[1]==$option)

What does $rows contain? What does $options contain?

You could also simplify this a little bit. I'd at least remove the foreach $options loop and use "in_array" - see

while ($rows = pg_fetch_array($result)) {
  $selected = '';
  if (in_array($rows[1], $options)) {
    $selected = ' SELECTED';
sprintf('<option value="%s"%s>%s</option>', $rows[1], $selected, $rows[1]);

Postgresql & php tutorials

[Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

Add to Google Powered by Linux