Re: HTML FORMS selected question - Mailing list pgsql-php

From
Subject Re: HTML FORMS selected question
Date
Msg-id 20061204175911.12201.qmail@web33304.mail.mud.yahoo.com
Whole thread Raw
In response to HTML FORMS selected question  ("Mag Gam" <magawake@gmail.com>)
List pgsql-php
----- Original Message ----
From: Mag Gam <magawake@gmail.com>
To: pgsql-php@postgresql.org
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.

pgsql-php by date:

Previous
From: Chris
Date:
Subject: Re: HTML FORMS selected question
Next
From: Chris
Date:
Subject: Re: cant conect to dynamic host-URL