jas4 Posted September 9, 2007 Share Posted September 9, 2007 Hi, If i pull say 10 email addresses from a mysql database, how can I show them onto the page, in a form along other inputs (e.g. an email message) so there are inputs like $message and $from, and then post these form values to sendForm.php, collect them and send an email to each email address - individulaly? My original idea was to send all the email addresses in a hidden field and collect them like this, but this obviously wont work becuase I'm sending other form data? $postvars = array(); foreach ($_POST as $interests => $value) { $postvars[] = $value; echo $value; } any advice or tips?? thanks Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/ Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 try something like <?php $sql = "SELECT email FROM mytable"; $res = mysql_query($sql); while ($row = mysql_fetch_row($res)) { $e_ads[] = $row[0]; } $to = join(';', $e_ads); ?> Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-344960 Share on other sites More sharing options...
jas4 Posted September 9, 2007 Author Share Posted September 9, 2007 yeh but then I want to send the $to string to a different form. So can I just do this like: <input type="hidden" value="<php echo $to; ?>"> and then use implode/explode at the other end? or is there a neter way to do it? Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-344967 Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 And the reason you can't put the "$to" variable from my example into a hidden field value is what? Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-344971 Share on other sites More sharing options...
jas4 Posted September 9, 2007 Author Share Posted September 9, 2007 erm i think thats what i did?? ^^^ <input type="hidden" value="<php echo $to; ?>"> Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-344984 Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 Sorry, misread the post. You need to name the hidden field <input type="hidden" name="emailto" value="<php echo $to; ?>"> Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-344989 Share on other sites More sharing options...
jas4 Posted September 9, 2007 Author Share Posted September 9, 2007 haha no worries. so at the other end all I need to do is: $email = $_POST['emailto'] which will be a string like: [email protected];[email protected];[email protected]........ so would I explode/implode $email into an array and then loop through it if i wanted to send an email to each address individually? thanks Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-345002 Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 yes, or you could prob send them all at once using the string as it is Link to comment https://forums.phpfreaks.com/topic/68621-storing-email-addresses-in-a-string/#findComment-345018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.