Computing.Net > Forums > Programming > php code to email mysql query to me

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

php code to email mysql query to me

Reply to Message Icon

Name: fetchhead
Date: May 17, 2004 at 15:12:09 Pacific
OS: linux
CPU/Ram: 2400, 1G
Comment:

I have a simple php form and mysql connection setup. The form collects data inserted by a user. I need to know when someone posts data and what that data is. I am trying to have php handle this by sending the results by email.

My results script already prints the table of the results:

$query = mysql_query("SELECT * FROM details WHERE $metode LIKE '%$search%'
LIMIT 0, 50");
while ($row = @mysql_fetch_array($query))
{
$variable1=$row["id"];
$variable2=$row["firstname"];
$variable3=$row["lastname"];
$variable4=$row["address"];
$variable5=$row["city"];
$variable6=$row["telephone"];
$variable7=$row["contact"];
//table layout for results

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("<td>$variable5</td>");
print ("<td>$variable6</td>");
print ("<td>$variable7</td>");
print ("</tr>");
}

What might I insert (if possible) to have these results also emailed to me?

BTW, I am hosting this on my own server so I have full access to whatever changes and sendmail functions on this server (linux SME Server).

Thx Craig Jensen




Sponsored Link
Ads by Google

Response Number 1
Name: rohinkoul
Date: May 18, 2004 at 00:13:18 Pacific
Reply:

Well you can use the mail function provided in php to sort out the things.

But for mail function to work you sendmail must be properly configured i.e sendmail should be able to send emails through conventional methods.

try using the mail functions instead of print in your script like this

mail ( "ur address", "subject","$variable1\n$variable2 ....","any additional headers you wanna send");

This should send the result of the query to you mail address.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: php code to email mysql query to me

How to write html code in perl? www.computing.net/answers/programming/how-to-write-html-code-in-perl/12668.html

php data from table mysql newbie www.computing.net/answers/programming/php-data-from-table-mysql-newbie/13702.html

PHP and MYSQL, query wont work www.computing.net/answers/programming/php-and-mysql-query-wont-work/10069.html