From: operationsengineer1@yahoo.com
To: Mag Gam <magawake@gmail.com>
To: pgsql-php@postgresql.org
Subject: Re: HTML FORMS selected question
Date: Mon, 4 Dec 2006 09:59:11 -0800 (PST)
Message-ID: <20061204175911.12201.qmail@web33304.mail.mud.yahoo.com> (raw)
----- 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.
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: operationsengineer1@yahoo.com, magawake@gmail.com
Subject: Re: HTML FORMS selected question
In-Reply-To: <20061204175911.12201.qmail@web33304.mail.mud.yahoo.com>
References: <20061204175911.12201.qmail@web33304.mail.mud.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox