Re: HTML FORMS selected question

From: <operationsengineer1(at)yahoo(dot)com>
To: Mag Gam <magawake(at)gmail(dot)com>, pgsql-php(at)postgresql(dot)org
Subject: Re: HTML FORMS selected question
Date: 2006-12-04 17:59:11
Message-ID: 20061204175911.12201.qmail@web33304.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

----- Original Message ----
From: Mag Gam <magawake(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)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

Browse pgsql-php by date

  From Date Subject
Next Message Chris 2006-12-05 23:15:16 Re: cant conect to dynamic host-URL
Previous Message Chris 2006-12-04 00:25:59 Re: HTML FORMS selected question