Re: HTML FORMS selected question

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



----- Original Message ----
From: Mag Gam <magawake@xxxxxxxxx>
To: pgsql-php@xxxxxxxxxxxxxx
Sent: Sunday, December 3, 2006 2:42:36 PM
Subject: [PHP] HTML FORMS selected question

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

//The values that need to be selected
$result_ip=pg_query($dbconn,$test_query);

<SELECT    NAME="ip[]" SIZE=10 MULTIPLE>
<?php
//This will show ALL values.
while($rows=pg_fetch_array($result)){
foreach ($options as $index => $option) {
    if ($rows[1]==$option)
    {
echo "<OptioN VALUE=\"$rows[0]\" selected=\"selected\">$rows[1]</Option> \n";
break;
        }
else
{
    echo "<OPTION VALUE=\"$rows[0]\">$rows[1]</OPTION> \n";
    break;
}
}
}

What am I doing wrong?

TIA!

---------------------------

Mag, i'm not sure what is wrong with the specific code, however, i'll make a suggestion that i think will help you more than just resolving this issue.

i recommend you look into learning a forms class.  the code will be much cleaner and the thought process is much more obvious.  the icing on the cake is the increased functionality you will get "out of the box" because some smart person coded it right into their forms class.  for example, i get client side and server side error checking and error message reporting.  i also get to have my form give focus to the first element via _javascript_.  there is some ajaxy stuff i haven't learned yet, but it is available.

i use Manuel Lemos' free forms generation and validation class which can be found on phpclasses.org.  iirc, the license is such that it can be included in proprietary commercial applications.  there are others, too.  i believe pear has one, along with some other functionality.

i'm very glad i went with a forms class instead of "htmling" it all.  i think you will be, too.

Manuel has a yahoo mailing list that is very helpful and reasonably active.  Most questions are answered within a day or so.

good luck.


Have a burning question? Go to Yahoo! Answers and get answers from real people who know.

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

  Powered by Linux