From: Mag Gam <magawake@gmail.com>
To: Randy Moller <zoomerz@comcast.net>
Cc: pgsql-php@postgresql.org
Subject: Re: HTML FORMS selected question
Date: Sun, 3 Dec 2006 18:43:31 -0500
Message-ID: <1cbd6f830612031543w26cdb6e2s82f1b958009d1b7@mail.gmail.com> (raw)
In-Reply-To: <20061203232352.A93629F9F8D@postgresql.org>
References: <457358D9.4000404@gmail.com>
<20061203232352.A93629F9F8D@postgresql.org>
Randy + Chris:
Thx for the quick replies!
Chris:
$rows contain ip addresses (postgresql inet) type (example: 192.168.0.1)
$options contain ip addresses (postgresql inet0 type (example: 127.0.0.1)
(keep in mind) they are both arrays. $rows contact all ips, and $options
contact the ip addresses that were selected
Randy:
I am not sure what you mean. The variables look right. I am getting no
errors! Just the logic is messed up.
HTH
On 12/3/06, Randy Moller <zoomerz@comcast.net> wrote:
>
> Maybe it's just a typo, but your pg_query is returning into the var
> $result_ip, while your fetch is referencing var $result (without _ip).
> Maybe that's just a typo for your question, but if not, that is at least
> one
> error.
>
> Also, it would be helpful to know what error you're getting....
>
> Randy Moller
>
> -----Original Message-----
> From: pgsql-php-owner@postgresql.org [mailto:
> pgsql-php-owner@postgresql.org]
> On Behalf Of Chris
> Sent: Sunday, December 03, 2006 4:08 PM
> To: Mag Gam
> Cc: pgsql-php@postgresql.org
> Subject: Re: [PHP] HTML FORMS selected question
>
> 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
> > $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)
> > {
>
>
> 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 php.net/in_array
>
> 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
> http://www.designmagick.com/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.430 / Virus Database: 268.15.6/565 - Release Date: 12/2/2006
> 9:39 PM
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.430 / Virus Database: 268.15.6/565 - Release Date: 12/2/2006
> 9:39 PM
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
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: magawake@gmail.com, zoomerz@comcast.net
Subject: Re: HTML FORMS selected question
In-Reply-To: <1cbd6f830612031543w26cdb6e2s82f1b958009d1b7@mail.gmail.com>
References: <457358D9.4000404@gmail.com> <20061203232352.A93629F9F8D@postgresql.org> <1cbd6f830612031543w26cdb6e2s82f1b958009d1b7@mail.gmail.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