Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down w/multiple columns

Status
Not open for further replies.

RPGguy

Programmer
Jul 27, 2001
73
US
I checked FAQ and came up empty so here goes:

I would like a drop down list showing 2 rows from my Customer table(customer number and name). When the user clicks I would like to return only the customer #. I'm using PHP, mySQL and HTML.

Thanks in advance for your help.

Scott
 
If you want to have lists with multiple columns, you will have to use ActiveX or Flash objects (or something similar). This can't be done in HTML. A work-around would be to generate the select list using padded PHP variables:

Code:
<select>
    <option value=&quot;<?= $strCustNum ?>&quot;><?= str_pad($strCustNum, 10, ' ', STR_PAD_LEFT) . ' ' . $strCustName ?></option>
</select>

Keep in mind that 10 represents the total length of the string, including padding, so make sure that that number is always greater than the largest number has digits.

Hope this helps.

Take Care,
Mike
 
Thanks Mike. I'm not clear though on what gets returned. Is it the customer # only or the whole string. If it's the string I assume I would have to parse out the number.
 
The only value that gets returned to the next page is whatever you decide to put in the value attribute of the option tag:

Code:
<option value=&quot;this gets returned&quot;>This does not get returned if value attribute is included</option>

Good luck :)

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top