Advertisement
Guest User

Untitled

a guest
Nov 14th, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.20 KB | None | 0 0
  1. <?php
  2.  
  3. function send_email() {
  4.    
  5.     $from = "donotreply@elitetradersgroup.com.au" ;
  6.     $headers  = 'MIME-Version: 1.0' . "\r\n";
  7.     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  8.     $headers .= "From: Elite Traders Group <".$from.">";
  9.    
  10.     $query = "SELECT user_email, email1, email2 FROM etg_users WHERE (subscribed = 1)" or die(mysql_error());
  11.     $result = mysql_query($query) or die(mysql_error());
  12.    
  13.     //If no result
  14.     if (!empty ($result)){
  15.         //Do stuff with the current row
  16.         while ($cur_row = mysql_fetch_array($result)) {
  17.             $string = "<html>";
  18.            $to = $cur_row['user_email'];
  19.             echo $to."<br />";
  20.             //Step across both columns, will need to be increased when more columns added
  21.             for($i = 1; $i <= 2; $i++){    
  22.                 //Build column name
  23.                 $email = "email".$i;    
  24.                 //If column name true                
  25.                 if ($cur_row[$email]){
  26.                     //Build the return
  27.                     make_email($i);
  28.                     $string .= $opost;
  29.                     $string .= "<br />";
  30.                  }                
  31.             }
  32.             $string .= "</html>";
  33.             $sent = mail($to, 'Test', $string, $headers) ;
  34.             if($sent) {
  35.                 echo "<br />Your trade request has been added to the cue you will be notifed upon sucessful trade lodgement";
  36.             } else {
  37.                 print "We encountered an error placing the trade, please try again.";
  38.             }
  39.             echo $string;
  40.             $string = null;
  41.         }
  42.     }
  43.  
  44. // /function
  45. }
  46.  
  47. function make_email($i) {    
  48.     switch ($i) {
  49.     //Com DMR
  50.     case 1:
  51.         email_post(33);
  52.         break;
  53.     //Com Market Highlights
  54.     case 2:
  55.         email_post(34);
  56.         break;
  57.     }
  58. }
  59.  
  60. function email_post($cat_id) {
  61.     global $post;
  62.     $args = array( 'numberposts' => 1, 'offset'=> 0, 'category' => $cat_id );
  63.     $myposts = get_posts( $args );
  64.     foreach( $myposts as $post ) :  setup_postdata($post); ?>
  65.             <h3><?php the_title(); ?></h3>
  66.             <?php the_excerpt();        
  67.     endforeach;    
  68. }
  69.  
  70. ?>
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement