a simple problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

a simple problem

Post by eshban »

hi ,

i am making a newsletter. There is a form and its has 3 fields:

to:
subject:
Message

there is a buttons, "get all members email address".

i want that when i click on "get all members email adress", my program will automatically fill the "TO" input box with all the available email addresses in databses.
how can i implement this

plz help in this regard.

bye
umbra
Forum Newbie
Posts: 21
Joined: Tue Sep 13, 2005 4:20 am

Post by umbra »

I think when you click that button you may form a query and store the email addresses in an array. Then you may redisplay the form with the results of that query in the TO field.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

Code: Select all

<?php
if (isset($_GET["action"])){
if ($_GET["action"] == "getAllMailAddresses"){
$toAddress = array();
$query = "select Email from Members_tbl";
$result = mysql_query($result);
if (is_resource($result)){
	if (mysql_num_rows($result)){
		while($row = mysql_row($result)){
			array_push($toAddress, $row[0]);
		}
	}
}
}
}

$mailList = implode(",",$toAddress)
?>

Code: Select all

<input type = 'text' name='to' value = '<?php echo $mailList; ?>' />
<input type = 'button' value = 'get all mail addresses' onclick = 'window.location=<?php echo $_SERVER["PHP_SELF"] ?>?action=getAllMailAddresses' />
Post Reply