Using SELECT

This is a discussion on Using SELECT within the PHP Language forums, part of the PHP Programming Forums category; I am developing a form that allows the user to enter data and upon submission, checks various databases, returns the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-06-2004
redneck_kiwi
 
Posts: n/a
Default Using SELECT

I am developing a form that allows the user to enter data and upon
submission, checks various databases, returns the data to the user so
they can confirm before submission to the database.

Two of the fields are employee names which are retrieved via a call to
the db:

<TD>Assign Rep/Mfg Hours To</TD>
<TD>
<SELECT NAME=arht>
<?
while ($myrow = mysql_fetch_array($emplist1)){
$arht=$myrow['lname'].", ".$myrow['fname'];
echo "<OPTION VALUE=$arht>$arht</OPTION>";
} ?>
</SELECT>
</TD>

As you can see, the field is built by concactinating the lname and
fname fields.

Once the FIRST submission button is clicked, I redisplay the form with
the values the user entered and the returned values from various db
searches that are performed.

I display the above selection by:

<TR>
<TD>Assign Rep/Mfg Hours To</TD>
<TD><INPUT TYPE=TEXT NAME=arht VALUE="<? echo $arht ?>"></TD>
<TD>Est. Project Set Up Time</TD><TD><INPUT TYPE=TEXT NAME=epsut
VALUE="<? echo $epsut ?>"></TD>
</TR>

Only problem is that I only see the 'lname' and the comma. The fname
field is not displayed. I can't seem to find where the problem is or
what I am doing wrong. Anyone see the obvious that I am not?
Thanks

rk

Reply With Quote
  #2 (permalink)  
Old 10-06-2004
Pedro Graca
 
Posts: n/a
Default Re: Using SELECT

redneck_kiwi wrote:
[snip]
> <?
> while ($myrow = mysql_fetch_array($emplist1)){
> $arht=$myrow['lname'].", ".$myrow['fname'];
> echo "<OPTION VALUE=$arht>$arht</OPTION>";



echo '<OPTION VALUE="', url_encode($arht), '">',
$arht, '</OPTION>';


or

echo "<OPTION VALUE='$arht'>$arht</OPTION>";
// _________________^_____^___

but I like the first version better :)


> } ?>

[snip]

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Reply With Quote
  #3 (permalink)  
Old 10-06-2004
Kevin Thorpe
 
Posts: n/a
Default Re: Using SELECT

redneck_kiwi wrote:

> I am developing a form that allows the user to enter data and upon
> submission, checks various databases, returns the data to the user so
> they can confirm before submission to the database.
>
> Two of the fields are employee names which are retrieved via a call to
> the db:
>
> <TD>Assign Rep/Mfg Hours To</TD>
> <TD>
> <SELECT NAME=arht>
> <?
> while ($myrow = mysql_fetch_array($emplist1)){
> $arht=$myrow['lname'].", ".$myrow['fname'];
> echo "<OPTION VALUE=$arht>$arht</OPTION>";
> } ?>
> </SELECT>
> </TD>
>
> As you can see, the field is built by concactinating the lname and
> fname fields.
>
> Once the FIRST submission button is clicked, I redisplay the form with
> the values the user entered and the returned values from various db
> searches that are performed.
>
> I display the above selection by:
>
> <TR>
> <TD>Assign Rep/Mfg Hours To</TD>
> <TD><INPUT TYPE=TEXT NAME=arht VALUE="<? echo $arht ?>"></TD>
> <TD>Est. Project Set Up Time</TD><TD><INPUT TYPE=TEXT NAME=epsut
> VALUE="<? echo $epsut ?>"></TD>
> </TR>
>
> Only problem is that I only see the 'lname' and the comma. The fname
> field is not displayed. I can't seem to find where the problem is or
> what I am doing wrong. Anyone see the obvious that I am not?
> Thanks


In your first code snippet you haven't quoted $ahrt in
<option value=$ahrt>
Reply With Quote
  #4 (permalink)  
Old 10-06-2004
redneck_kiwi
 
Posts: n/a
Default Re: Using SELECT

Thanks! Both work, however using urlencode (you had an underscore) gave
me fname%2C+lname in the input field on the confirmation page. Guess
I'd have to urldecode on the display side to correct that!
Enclosing ('$arht') did the trick though!

Thanks

rk

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:38 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0