hanwei Posted November 1, 2006 Share Posted November 1, 2006 hi guys, i need some help here.i have created a table in my database. And i would like to send the table to my email everyday at a certain time. i know i have to use crontab.but right now is how do i display the table and send it over to my mail?i have tried to use the following:$to="myemailaddress"$subject="mysubject"$headers="myheaders"$message="mymessage"mail($to,$subject,$message,$headers)it will send a mail to my mailbox. but now i wanted to send over all the data in a table.so can anyone give me some idea on how to do it?thanks in advance. Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/ Share on other sites More sharing options...
Orio Posted November 1, 2006 Share Posted November 1, 2006 http://www.phpfreaks.com/script/view/11.phpOrio. Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117743 Share on other sites More sharing options...
hanwei Posted November 1, 2006 Author Share Posted November 1, 2006 erm.. thanks, but what i want is to send a daily report to my email. not doing a backup.for example: Number of Client online : ___Number of Client submitted: ___i just want a simple text base report to be sent to my mail. But all the data i have to retrive from my table so that i can display it and send to my mail.thanks in advance Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117746 Share on other sites More sharing options...
Orio Posted November 1, 2006 Share Posted November 1, 2006 Where and how do you have that information stored exactly? (Table structures).Orio. Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117749 Share on other sites More sharing options...
hanwei Posted November 1, 2006 Author Share Posted November 1, 2006 the table is in a database. all the data in the tables is updated everday.if i executemysql>select * from mytable\G;output is:ClientName:___LoginDate:___LoginTime:___so i have to mail a list of client who login into my web.if i'm not wrong, i use the select * from mytable where LoginDate='xxx'; to get the data i want. but i'm not sure how to mail it in text/html form.thanks in advance Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117751 Share on other sites More sharing options...
redarrow Posted November 1, 2006 Share Posted November 1, 2006 [code]<?php$db=mysql_connect('localhost' , 'xxxxxx' , 'xxxxxx' );mysql_select_db('xxxxxx',$db);$query="select * from xxxxxx where xxxxx='xxxxx'";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){$to = $record['email_address'];$subject = 'Wakeup bob!';$message = 'memeber $record['user'] logeed in at $record['date']';$headers = "From: [email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n";// Sendmail($to, $subject, $message, $headers);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117753 Share on other sites More sharing options...
hanwei Posted November 1, 2006 Author Share Posted November 1, 2006 i think have to put a mysql_close($db) at the end of the script right? now i'm waiting for it to reach my mail.[quote author=redarrow link=topic=113442.msg461008#msg461008 date=1162375437][code]<?php$db=mysql_connect('localhost' , 'xxxxxx' , 'xxxxxx' );mysql_select_db('xxxxxx',$db);$query="select * from xxxxxx where xxxxx='xxxxx'";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){$to = $record['email_address'];$subject = 'Wakeup bob!';$message = 'memeber $record['user'] logeed in at $record['date']';$headers = "From: [email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n";// Sendmail($to, $subject, $message, $headers);}?>[/code][/quote] Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117757 Share on other sites More sharing options...
redarrow Posted November 1, 2006 Share Posted November 1, 2006 mysql_close() is only if you use the pconnect ok.persistent connection Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117760 Share on other sites More sharing options...
hanwei Posted November 1, 2006 Author Share Posted November 1, 2006 oh.. thanks alot. i learn something new today..:D Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-117762 Share on other sites More sharing options...
hanwei Posted November 2, 2006 Author Share Posted November 2, 2006 i'hv change my script to this<?php$link = mysql_connect("127.0.0.1", "mysql") or die("Could not connect: " . mysql_error());mysql_select_db("ttmodule", $link) or die("Unable to select database: . mysql_error()");$query="select userID, logTime from mytable";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){$to = "hanwei<[email protected]>";$subject = "Test";$message = ' member $record["userID"] logged in $record["logTime"] ';$headers = "From: [email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n";// Sendmail($to, $subject, $message, $headers);}?>the mail i got is:member $record["userID"] logged in $record["logTime"]it directly print out the message.can someone help me?thanks in advance Link to comment https://forums.phpfreaks.com/topic/25787-need-help-in-sending-php-data-to-email-in-htmltext-formatclosed/#findComment-118215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.