By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,713 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,713 IT Pros & Developers. It's quick & easy.

Using SELECT

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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>
Jul 17 '05 #2

P: n/a
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. |
Jul 17 '05 #3

P: n/a
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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.