I have this little logic that i dont get how to solve it.
I have this on my database named email_list
5 records
then i have this trackCode
15 records on it.
my problem is im doing something like when i click the email all
it will get the email to my email_list
which has 5 records then the trackCode will send it to those emails.
i have this code
$sql = mysql_query( "SELECT * FROM code WHERE track = '$_POST['track']' " ) or die ( mysql_error() );
$row = mysql_fetch_array( $sql );
$subject = 'You have received your code';
$message = '
Your code is '.$row['trackCode'].'
Please click here to activate your code - click here -
management
';
$header = "From: noreply@fastindexer.com \r\n";
$header .= 'Content-type: text/html' . "\r\n";
$sqlemail = mysql_query( "SELECT * FROM email_list ORDER BY rand() LIMIT 15" ) or die ( mysql_error() );
while ( $rowemail = mysql_fetch_array( $sqlemail ) ) {
$to = $rowemail['emails'];
}
$send_contact = mail($to,$subject,$message,$header);
Can you tell me what is wrong with my code is it my while statement?
What im trying to solve is that when it send email it send to those 5 emails with different trackCodes
i think im lost with my process and logic.
thanks guys