GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Feb-2009, 17:12
wendyz wendyz is offline
New Member
 
Join Date: Feb 2009
Posts: 6
wendyz is on a distinguished road

Question about mail()


I store several data in database with the same tracking number, now I get those data from database and send email to someone. the problem is how can I store those data in to $message line by line. example:
in database I have
Code:
key department subject 1 usergroup testing1 1 usergroup testing2 1 other testing3

then after I select data by $mysql_query($sql)
I should get all data with key=1, and save into $message, then I can use
mail($to,$subject, $message) send email, I will get all information in the mail.

But I use $mysql_fetch_array($sql), only save last record into $message, anyone can help me?
  #2  
Old 24-Feb-2009, 18:37
wendyz wendyz is offline
New Member
 
Join Date: Feb 2009
Posts: 6
wendyz is on a distinguished road

Re: Question about mail()


I fix this problem
  #3  
Old 24-Feb-2009, 23:47
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 858
admin will become famous soon enough

Re: Question about mail()


Assuming the data was queried this way:

PHP Code:

<?php
    // stores the (email) message
    $message = null;
    // get the data off the database table
    $sql =
        "SELECT * 
        FROM `my_table`
        WHERE `key`=1";

    if( $resource=mysql_unbuffered_query($sql, $conn) )
    {
        while( $row=mysql_fetch_assoc($resource) )
        {
            $message .= implode( "\t", $row ). "\n";
        }
    }

    if( $message )
    {
        // send an email
        mail( "example@example.com", "My Subject", $message );
    }

?>


That would do the trick.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please, This is Difficult question try for me! bcompt143 C++ Forum 4 24-Aug-2008 09:14
Reliable Hosting $2-$8/month: PHP, MySQL, FrontPage, CGI, SSH, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 04-Nov-2003 06:03
Guestbook error BobbyDouglas Web Design Forum 1 16-Oct-2003 22:17
600MB Space, 20GB Banwidth, PHP, MySQL, CGI, SSH, FrontPage, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 08-Aug-2003 10:11
Yahoo! Mail (POP Access) nniehoff Open Discussion Forum 1 17-Jan-2003 06:55

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:00.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.