seany123 Posted February 4, 2010 Share Posted February 4, 2010 im trying to make a mass mail page wher i can mass mail everyone but im not too sure how to do it... this is what i would do to message 1 person. $query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`) values (?, ?, ?, ?)", array($insert['to'], $insert['from'], $insert['body'], $insert['subject'])); the members are stored in member table so basically what i think need to do is: $query = $db->execute("SELECT id FROM members"); $member = $query->fetchrow(){ $query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`) values (?, ?, ?, ?)", array($member, $insert['from'], $insert['body'], $insert['subject'])); } is that right? Link to comment https://forums.phpfreaks.com/topic/190906-help-with-code/ Share on other sites More sharing options...
trq Posted February 4, 2010 Share Posted February 4, 2010 Surely you will need to loop through the results of your query. Link to comment https://forums.phpfreaks.com/topic/190906-help-with-code/#findComment-1006743 Share on other sites More sharing options...
seany123 Posted February 4, 2010 Author Share Posted February 4, 2010 $query = $db->execute("SELECT id FROM members"); while($member = $query->fetchrow()){ $query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`) values (?, ?, ?, ?)", array($member, $insert['from'], $insert['body'], $insert['subject'])); } ?? Link to comment https://forums.phpfreaks.com/topic/190906-help-with-code/#findComment-1006749 Share on other sites More sharing options...
trq Posted February 4, 2010 Share Posted February 4, 2010 Even then, I would assume $member is an array. Try... $query = $db->execute("insert into `mail` (`to`, `from`, `body`, `subject`) values (?, ?, ?, ?)", array($member['id'], $insert['from'], $insert['body'], $insert['subject'])); Link to comment https://forums.phpfreaks.com/topic/190906-help-with-code/#findComment-1006750 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.