Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function send_email() {
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= "From: Elite Traders Group <".$from.">";
- $query = "SELECT user_email, email1, email2 FROM etg_users WHERE (subscribed = 1)" or die(mysql_error());
- $result = mysql_query($query) or die(mysql_error());
- //If no result
- if (!empty ($result)){
- //Do stuff with the current row
- while ($cur_row = mysql_fetch_array($result)) {
- $string = "<html>";
- $to = $cur_row['user_email'];
- echo $to."<br />";
- //Step across both columns, will need to be increased when more columns added
- for($i = 1; $i <= 2; $i++){
- //Build column name
- $email = "email".$i;
- //If column name true
- if ($cur_row[$email]){
- //Build the return
- make_email($i);
- $string .= $opost;
- $string .= "<br />";
- }
- }
- $string .= "</html>";
- $sent = mail($to, 'Test', $string, $headers) ;
- if($sent) {
- echo "<br />Your trade request has been added to the cue you will be notifed upon sucessful trade lodgement";
- } else {
- print "We encountered an error placing the trade, please try again.";
- }
- echo $string;
- $string = null;
- }
- }
- // /function
- }
- function make_email($i) {
- switch ($i) {
- //Com DMR
- case 1:
- email_post(33);
- break;
- //Com Market Highlights
- case 2:
- email_post(34);
- break;
- }
- }
- function email_post($cat_id) {
- global $post;
- $args = array( 'numberposts' => 1, 'offset'=> 0, 'category' => $cat_id );
- $myposts = get_posts( $args );
- foreach( $myposts as $post ) : setup_postdata($post); ?>
- <h3><?php the_title(); ?></h3>
- <?php the_excerpt();
- endforeach;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment