PHP HELP!
- Started
- Last post
- 7 Responses
- bigredmailbox
Hi,
I was just wondering what the script would be to fetch email addresses from a db an put them in a dropdown menu. Please help. Thanks in advance.
- fusionpixel0
There is no one script that says "Fetch email addresses and put them in a drop down"
You need to
1. connect to the database
2. find the column where all your email addresses are
3. create the drop down
4. add the information from the database to the dropdown
5. decide what you want to do once the user uses the drop down
a) launch their email client
b) open a new page
c) do nothing
6. of course the final step where to place the dropdownSoooo.... which one of these steps do you need help with?
- bigredmailbox0
I need help with:
Adding information from the database to the dropdown.
- fusionpixel0
you can do something like:
$query = "SELECT email FROM yourDB";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['email'];
echo "";
}if you cant see the above is because NT wont show scripts
- bigredmailbox0
ok?
That did not work?
umm.i have my drop down so what bit of that do i put so it shows up in the drop down. And i see that ic connects to the DB and gets the email but how does it know what table?????????
- fusionpixel0
uh?
...php.net
- welded0
$html .= '[select name="email"]';
while($row = mysql_fetch_array($r esult)){
$html .= '[option value="' . $row['email'] . '"]' . $row['email'] . '[/select]\n';
}
$html .= '[/select]';echo $html;
There may be a syntax error or two here, but this will do the trick. You'll still need the db connection code.
- cosmo0
dude what is your knowledge on php? do you have any books that can help you?