I tried to query a table and retrieve some data, then I email them to an indivisual person with different data. However, I am only to send the 1st email, but not 2nd email. My query seem that not able to pass the 1st data found and pass it for 2nd time quer. Here is my code:
<?php require "connection.php"; $today = date("Y-m-d"); $query1 = mysql_query("SELECT no FROM invno WHERE date='$today'"); while ($row1 = mysql_fetch_array($query1, MYSQL_NUM)){ $no=$row1[0]; $headers .= "From: Your Valueble Hosting Partner \n"; $headers .= "X-Sender: \n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "X-Priority: 1\n"; // Urgent message! $headers .= "Return-Path: \n"; // Return path for errors /* If you want to send html mail, uncomment the following line */ $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $query = mysql_query("SELECT * FROM invoice WHERE no='$no'"); while ($row = mysql_fetch_array($query, MYSQL_NUM)){ $domain=$row[1]; $cname=$row[5]; $email=$row[7]; $expire=$row1[4]; $total=$row[9]; $amount=$row[12]; $id=$row[13]; $price=$total+$amount; } /* subject */ $subject="Your http://$domain Invoice"; /* recipients */ $recipient .= "$email"; /* message */ $message .= "Hello! $cname,"; $message .= "Your domain http://$domain is going to be expired on $expire.
"; $message .= "Please click here to view your Invoice.
"; $message .= "Your TOTAL invoice due is $price.
"; $message .= "You can pay your invoice here or
"; $message .= "bank in your payment as below information that we provided:-
"; $message .= "----------------------------------------------------
"; $message .= "Banker: ABC Bank
"; $message .= "Account No: 123456
"; $message .= "Company Name: ABC Hosting
"; $message .= "Payment Due: $price
"; $message .= "----------------------------------------------------
"; $message .= "Please make your payment by the due date to advoid service interraption.
"; $message .= "If you have paid, pls ignore the email.
"; $message .= "Thank you for your business.
"; $message .= "Have a nice day!
"; $message .= "Remarks: This email is computer generated document.
"; $message .= "Regards,
"; $message .= "Sales Team of tech Hosting Service"; // start while // we use the sql var. $row and we use the field 0 to pickup the email address //echo "$domain $row[0]
"; mail($recipient, $subject, $message, $headers); } ?>