Current location: Hot Scripts Forums » Programming Languages » PHP » Repeating MySQL records in a mail script


Repeating MySQL records in a mail script

Reply
  #1 (permalink)  
Old 07-22-03, 12:23 PM
watix watix is offline
New Member
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Repeating MySQL records in a mail script

I am trying to search a MySQL database... select a number of the records and then email them.

If I create a QUERY and then run the following email lines...
----------------------------------------------------------------------
$to = "me@myweb.com";
$subject = "Website Info";
$message = "hello message\n\n";
$message .= $row_rcdInfo['ItemID'] . "\n\n";
$message .= $row_rcdInfo['Name'] . "\n\n";
$message .= $row_rcdInfo['Quantity'] . "\n\n";
$from = "From: Website <info@myweb.com>";
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= $from; // set the from field in the header
$header .= "\n"; // add a line feed
mail($to, $subject, $message, $header); // send the e-mail
----------------------------------------------------------------------

The first record is sent fine... I am just not sure how to incorporate a repeat region in this senario... essentially can anyone let me know the best way of emailing data (or if there are any extentions out there) from a MySQL database...
Reply With Quote
  #2 (permalink)  
Old 07-22-03, 02:28 PM
Man Down Man Down is offline
HS Staff
 
Join Date: Jun 2003
Location: Maryland
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
You could use the while functions

PHP Code:

<?

$to 
"me@myweb.com";
$subject "Website Info";
$message "hello message\n\n";


while(
$rrow_rcdInfo mysql_fetch_array($result)) {
    
$message .= $row_rcdInfo['ItemID'] . "\n\n";
    
$message .= $row_rcdInfo['Name'] . "\n\n";
    
$message .= $row_rcdInfo['Quantity'] . "\n\n";
}

$from "From: Website <info@myweb.com>";
$header "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= $from// set the from field in the header
$header .= "\n"// add a line feed
mail($to$subject$message$header); // send the e-mail
?>
If you need help understanding this code let me know.
__________________
Man Down
Reply With Quote
  #3 (permalink)  
Old 07-22-03, 05:25 PM
watix watix is offline
New Member
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Many thanks Man Down...
That's done the trick...

Cheers
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
mysql - auto deletion of records munricer Script Requests 0 10-05-03 03:21 PM
PHP + MySQL script help need andyinorbit2000 PHP 1 09-09-03 02:07 AM
Basic script that use MySQL EST Script Requests 3 09-07-03 06:19 PM
a mysql news script darkcarnival General HotScripts Site Discussion 2 07-25-03 10:49 AM


All times are GMT -5. The time now is 05:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.