This is a discussion on e-mail contents of mysql databse NOT within the PHP Language forums, part of the PHP Programming Forums category; I have have tried to find the answere to this on line but without success! I have a table called ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have have tried to find the answere to this on line but without success!
I have a table called cart. In cart I have a column called ID. What I need to do is take this code: <?php $result = mysql_query("SELECT * FROM cart WHERE cartId='$ID'"); bla bla bla <?php echo $row["ItemNo"]; ?> </font></td> <td width="22%" height="6"><font face="verdana" size="2" color="red"> <?php echo $row["Name"]; ?> </font></td> <td width="14%" height="6"> <div align="center"><font face="verdana" size="1" color="black"> <?php echo $row["Quantity"]; ?> </font></div> </td> <td width="7%" height="6" > </td> <td width="10%" height="6" > <div align="left"><font face="verdana" size="1" color="blue"> $ <?php echo number_format($row["Price"], 2, ".", ","); ?> </font> </div> </td> <td width="7%" height="6"> <div align="left"><font face="verdana" size="1" color="blue"> <?php $Cost += ($row["Quantity"] * $row["Price"]); ?> <?php $ItemCost = ($row["Quantity"] * $row["Price"]); ?> bla bla and somehow e-mail it to the client. I would like to use the mail() function but can't seem to get $message= to accept it. IS there a way to do this. If not how do I e-mail the contents of cartId='$ID to the client to process. I'm new at this and fumbling my way through. Any suggestions would be appreciated. Thanks Michael |
|
|||
|
de Beers wrote:
> I have have tried to find the answere to this on line but without success! > > I have a table called cart. In cart I have a column called ID. What I need > to do is take this code: > > <?php > > $result = mysql_query("SELECT * FROM cart WHERE cartId='$ID'"); > > bla bla bla > > <?php echo $row["ItemNo"]; ?> > </font></td> > <td width="22%" height="6"><font face="verdana" size="2" color="red"> > <?php echo $row["Name"]; ?> > </font></td> > <td width="14%" height="6"> > <div align="center"><font face="verdana" size="1" color="black"> > <?php echo $row["Quantity"]; ?> > </font></div> > </td> > <td width="7%" height="6" > </td> > <td width="10%" height="6" > > <div align="left"><font face="verdana" size="1" color="blue"> $ > <?php echo number_format($row["Price"], 2, ".", ","); ?> > </font> </div> > </td> > <td width="7%" height="6"> > <div align="left"><font face="verdana" size="1" color="blue"> > <?php > $Cost += ($row["Quantity"] * $row["Price"]); > > ?> > <?php > $ItemCost = ($row["Quantity"] * $row["Price"]); > > ?> > > bla bla > > and somehow e-mail it to the client. > > I would like to use the mail() function but can't seem to get $message= to > accept it. > > IS there a way to do this. If not how do I e-mail the contents of > cartId='$ID to the client to process. > > I'm new at this and fumbling my way through. Any suggestions would be > appreciated. > > Thanks > > Michael > > Rather than use this interweaving of html and php, which is very common, but I personally find as readable as a plate of spaghetti, build up a string that contains what you want to display, then echo that variable to display the page... ie it contains all the hml as well as the php vars you use. That can then become the basis for your message. eg... <?php $Message = '$row["ItemNo"]'; $Message .= ' </font></td>'; $Message .= '<td width="22%" height="6"><font face="verdana" size="2" color="red">'; $Message .= $row["Name"]; $Message .= '</font></td><td width="14%" height="6">'; $Message .= '<div align="center"><font face="verdana" size="1" color="black">'; $Message .= $row["Quantity"]; $Message .= '</font></div></td>'; $Message .= '<td width="7%" height="6" > </td>'; $Message .= '<td width="10%" height="6" >'; $Message .= '<div align="left"><font face="verdana" size="1" color="blue">'; $Message .= number_format($row["Price"], 2, ".", ","); $Message .= '</font> </div>'; $Message .= '</td>'; $Message .= '<td width="7%" height="6">'; $Message .= '<div align="left"><font face="verdana" size="1" color="blue">'; $Cost += ($row["Quantity"] * $row["Price"]); $ItemCost = ($row["Quantity"] * $row["Price"]); $Recipient = "steve@my.email.address"; $Title = "Email title " . date ("d-M-Y"); $Message .= "Mail Message"; mail ( $Recipient, $Title, $Message ); echo $Message; ?> |
|
|||
|
What you are doing is <?php echo .....; ?> and therefore outputting it
on the screen. Just declare a $message in the beginning of the script and then extend the $message variable with $message .= "bla di bla di bla"; Then call the mail-function where the body parameter is your $message. Mark de Beers wrote: > I have have tried to find the answere to this on line but without success! > > I have a table called cart. In cart I have a column called ID. What I need > to do is take this code: > > <?php > > $result = mysql_query("SELECT * FROM cart WHERE cartId='$ID'"); > > bla bla bla > > <?php echo $row["ItemNo"]; ?> > </font></td> > <td width="22%" height="6"><font face="verdana" size="2" color="red"> > <?php echo $row["Name"]; ?> > </font></td> > <td width="14%" height="6"> > <div align="center"><font face="verdana" size="1" color="black"> > <?php echo $row["Quantity"]; ?> > </font></div> > </td> > <td width="7%" height="6" > </td> > <td width="10%" height="6" > > <div align="left"><font face="verdana" size="1" color="blue"> $ > <?php echo number_format($row["Price"], 2, ".", ","); ?> > </font> </div> > </td> > <td width="7%" height="6"> > <div align="left"><font face="verdana" size="1" color="blue"> > <?php > $Cost += ($row["Quantity"] * $row["Price"]); > > ?> > <?php > $ItemCost = ($row["Quantity"] * $row["Price"]); > > ?> > > bla bla > > and somehow e-mail it to the client. > > I would like to use the mail() function but can't seem to get $message= to > accept it. > > IS there a way to do this. If not how do I e-mail the contents of > cartId='$ID to the client to process. > > I'm new at this and fumbling my way through. Any suggestions would be > appreciated. > > Thanks > > Michael > > |
|
|||
|
You could also try:
1) ob_start(); 2) echo your table out in html 3) $contents = ob_get_contents(); 4) ob_end_clean(); 5) $filename="/path/file.html"; $fp=fopen($filename,"w"); 6) fputs($fp, $contents); fclose($fp); 7) passthru("htmldoc -f attachment.pdf --left .75in --right .75in --top ..2in --bottom .2in --linkstyle plain --linkcolor black --footer . --webpage $filename"); 8) Use Mutt to mail it out: passthru("/usr/local/bin/mutt -F /path/to/mutt/conffile/muttrcconffile -a /path/attachment.pdf -s \"Email From You\" $emailaddress < /path/emailbodytext.txt"); Then your client gets his email in a pdf attachment! htmldoc will let you embed links into that pdf, too. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|