Page 1 of 1

a simple problem

Posted: Wed Sep 14, 2005 5:11 am
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

Posted: Wed Sep 14, 2005 6:42 am
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.

Posted: Wed Sep 14, 2005 7:22 am
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' />