Jump to content

[SOLVED] Echo email form is in a loop


steviemac

Recommended Posts

Hi,

I have e-mail addresses in a table and I want to be able to send one email to all users. Right now I am echoing a form for each email address in the table.  I just want one form.

This is what I have tried

 

<?php 



$query = "SELECT email_address as email FROM IDC"; 
$result = mysql_query($query) or die(mysql_error()); {
///This TD of links and TD of Location
while($record = mysql_fetch_array($result)) {

  
   {echo "<form action=\"email.php\" method=\"post\">";
   echo "<table border=\"1\"><tr><td valign=\"top\" class=\"tdeight\">";
echo "<p>From  <br> <input NAME=\"name\" value=\"Bonnie Bruno\" size=\"30\"></p>";
echo "<P> E-Mail Address<br><input NAME=\"email\" size=\"30\" value=\"$record[email];\"</p>";
echo "<p>Subject<br>  <input NAME=\"subject\" size=\"30\"</p>";
echo "<p>Comments<br>  <textarea name=\"comments\" rows=\"10\" cols=\"30\" ></textarea></p>";
echo "<center><input type=\"submit\" Value=\"Send\" name=\"submit\"><input type=\"reset\" value=\"Reset\" name=\"reset\"></center>";
echo "</td></tr></table>";

echo "</form>";
}
  

   
}

}
?>

 

Can anyone point in the right direction where it will be just one form and all the email addresses go into the form field of email.

 

Thank you for your time.

Link to comment
https://forums.phpfreaks.com/topic/42117-solved-echo-email-form-is-in-a-loop/
Share on other sites

Just make the while loop output the value of the textbox:

 

<?php
//beginning form stuff here
echo "<p>E-Mail Address<br><input NAME=\"email\" size=\"30\" value=";

while($record = mysql_fetch_array($result)) {
  echo $record['email'] . ",";
}

echo "></p>";
//rest of form stuff
?>

Archived

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

×
×
  • Create New...

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.