Jump to content

Archived

This topic is now archived and is closed to further replies.

simcoweb

Can you populate the <SELECT> list from a database?

Recommended Posts

I just need to know if this can be done. I have a contact form that is asking for a 'referrer' selection (who referred you) to be a dropdown menu. What i'd like to do is to generate the selections in that list from the member's list in the database instead of hard-coding it into the form each time we add or lose member.

Another 'key' is that I need the referrer's ID # to pass as well so that reports can be created using the ID# as the search key. So, basically when the visitor selects from the member list to choose the referrer that referrer's name is entered into a new table along with their ID# and the person they referred to.

Share this post


Link to post
Share on other sites
Yes, it can. Query the member table and make the option values the memberID and display member name.

<option value = '$id' > $name </option>

Having selected the referrer you only need store the referrer's id in the new table and not the name. You can get the name by joining to the member table.

Share this post


Link to post
Share on other sites
Barand, as usual you rock.

I'll need to brush up on the 'Join' part of the database structures. I'm not at all familiar with how that works and how to construct it. You've mentioned it before in previous posts. Is there a PHPFreaks tutorial on it somewhere?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.