Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

HTML table with Database information in Body

the mail() function

Moderators: macek, egami, gesf

HTML table with Database information in Body

Postby jainuttam » Sat Jan 19, 2013 2:52 am

Hi,
i want to display the database information through the mail to the users for that i am getting the information in individual entries. i need one header under that all the database information.
i have uploaded the image of the email.

any help ?
I am not able to figure out the exact problem.

Code
<?php
$query = "SELECT emailid FROM users WHERE members='{$_SESSION['members']}'";
$result1 = mysql_query($query) or die(mysql_error());
$data1 = mysql_fetch_assoc($result1);
$email = $data1['emailid'];


$sql="SELECT sitelist.sno, sitelist.code, sitelist.sitename, sitelist.taluk, sitelist.district, sitelist.members, Junevisit.visitdate, Julyvisit.visitdate2, Augustvisit.avisitdate, Septvisit.svisitdate, Octvisit.ovisitdate, Novvisit.nvisitdate, Decvisit.dvisitdate, Jan13visit.j13visitdate
FROM sitelist
INNER JOIN Junevisit
ON sitelist.code=Junevisit.code
INNER JOIN Julyvisit
ON sitelist.code=Julyvisit.code
INNER JOIN Augustvisit
ON sitelist.code=Augustvisit.code
INNER JOIN Septvisit
ON sitelist.code=Septvisit.code
INNER JOIN Octvisit
ON sitelist.code=Octvisit.code
INNER JOIN Novvisit
ON sitelist.code=Novvisit.code
INNER JOIN Decvisit
ON sitelist.code=Decvisit.code
INNER JOIN Jan13visit
ON sitelist.code=Jan13visit.code
WHERE sitelist.members='{$_SESSION['members']}' OR sitelist.DC='{$_SESSION['members']}' ORDER BY sitelist.members ASC, sitelist.taluk ASC ";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){

$to = "$email1, xyz@xyz.com";
$subject = "xyz";

$message .="
<table width=\"100%\">
<tr>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>Sl.No</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>Site code</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>Site_Name</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>Taluk</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>District</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>DC/SE</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>August Visit</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>September Visit</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>October Visit</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>November Visit</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>December Visit</strong></th>
<th bgcolor=\"#0099FF\"><font color=\"white\"><strong>January.13 Visit</strong></th>
</tr>";





"<tr>
<td><font size=\"1px\">" . $rows['sno'] . "</td>
<td><font size=\"1px\">" . $rows['code'] . "</td>
<td><font size=\"1px\">" . $rows['sitename'] . "</td>
<td><font size=\"1px\">" . $rows['taluk'] . "</td>
<td><font size=\"1px\">" . $rows['district'] . "</td>
<td><font size=\"1px\">" . $rows['members'] . "</td>
<td><font size=\"1px\">" . $rows['avisitdate'] . "</td>
<td><font size=\"1px\">" . $rows['svisitdate'] . "</td>
<td><font size=\"1px\">" . $rows['ovisitdate'] . "</td>
<td><font size=\"1px\">" . $rows['nvisitdate'] . "</td>
<td><font size=\"1px\">" . $rows['dvisitdate'] . "</td>
<td><font size=\"1px\">" . $rows['j13visitdate'] . "</td>

</tr>
</table>
";

}



// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

mail($to,$subject,$message,$headers);
?>
Attachments
image.JPG
image.JPG (57.93 KiB) Viewed 1341 times
jainuttam
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Jan 19, 2013 2:05 am

Re: HTML table with Database information in Body

Postby jainuttam » Mon Jan 21, 2013 1:13 am

Can i provide the solution to this
jainuttam
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Jan 19, 2013 2:05 am

Re: HTML table with Database information in Body

Postby jainuttam » Sat Jan 26, 2013 7:02 am

please provide the solution
jainuttam
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Jan 19, 2013 2:05 am

Re: HTML table with Database information in Body

Postby jainuttam » Wed Feb 06, 2013 10:10 pm

only views to post but no solution
jainuttam
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Jan 19, 2013 2:05 am

Re: HTML table with Database information in Body

Postby seandisanti » Fri Mar 01, 2013 11:56 am

What error are you getting? You can't just say, "here's my code, make it work"; you have to say what it's doing or not doing versus what you would like it to do, and then people can let help you solve the issue. A lot of us are happy to help, but nobody wants to just jump in and take over with no idea what's going wrong -especially when even trying to recreate the error would require creating a database, tables, and sample data based on code that you have already said is not working.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 787
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron