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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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. | |
|
|||
|
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> |
|
|||
|
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 |