5 Replies - 1765 Views - Last Post: 28 March 2012 - 04:27 PM Rate Topic: -----

#1 JonQCoder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 44
  • Joined: 23-May 11

Generating HTML with php for email newsletter

Posted 27 March 2012 - 02:51 PM

I've created an html newsletter and everything is setup like I want. The only problem right now is, I have to manually enter any of the information in the newsletter. This information is already stored in a database from a drupal website and other people(Not programmers) may need to send the newsletter out in my absence. What I want to do is write a php script of some sort that will go and get the information. I would need it to generate an html file with the data it got in the appropriate places.

I'm not sure how to go about it. The newsletter html template is pretty large. Everything I found online as far as email html newsletters goes said I had to use nested tables because email clients take things out and ignore other things. Just looking for some help getting started in the right direction, maybe a small example? I'm sure I could get most of this to a file, but I really doubt it's the most effective way of doing so(Lots of echos). If any other information is needed, please let me know. :)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <!-- Facebook sharing information tags -->
        <meta property="og:title" content="*|MC:SUBJECT|*">
        
        <title>Medications & More Newsletter</title>
		
	<style type="text/css">
		#outlook a{
			padding:0;
		}
		body{
			width:100% !important;
		}
		.ReadMsgBody{
			width:100%;
		}
		.ExternalClass{
			width:100%;
		}
		body{
			-webkit-text-size-adjust:none;
		}
		body{
			margin:0;
			padding:0;
		}
		img{
			border:0;
			height:auto;
			line-height:100%;
			outline:none;
			text-decoration:none;
		}
		table td{
			border-collapse:collapse;
		}
		#backgroundTable{
			height:100% !important;
			margin:0;
			padding:0;
			width:100% !important;
		}
	/*
	@tab Page
	@section background color
	@tip Set the background color for your email. You may want to choose one that matches Hale Publishing's branding.
	@theme page
	*/
		body,#backgroundTable{
			/*@editable*/background-color:#FAFAFA;
		}
	/*
	@tab Page
	@section email border
	@tip Set the border for your email.
	*/
		#templateContainer{
			/*@editable*/border:1px solid #DDDDDD;
		}
	/*
	@tab Page
	@section heading 1
	@tip Set the styling for all first-level headings in emails. These should be the largest of the headings.
	@style heading 1
	*/
		h1,.h1{
			/*@editable*/color:#202020;
			/*@editable*/display:block;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:34px;
			/*@editable*/font-weight:bold;
			/*@editable*/line-height:100%;
			/*@editable*/margin-top:0 !important;
			/*@editable*/margin-right:0 !important;
			/*@editable*/margin-bottom:10px !important;
			/*@editable*/margin-left:0 !important;
			/*@editable*/text-align:left;
		}
	/*
	@tab Page
	@section heading 2
	@tip Set the styling for all second-level headings in emails.
	@style heading 2
	*/
		h2,.h2{
			/*@editable*/color:#202020;
			/*@editable*/display:block;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:30px;
			/*@editable*/font-weight:bold;
			/*@editable*/line-height:100%;
			/*@editable*/margin-top:0 !important;
			/*@editable*/margin-right:0 !important;
			/*@editable*/margin-bottom:10px !important;
			/*@editable*/margin-left:0 !important;
			/*@editable*/text-align:left;
		}
	/*
	@tab Page
	@section heading 3
	@tip Set the styling for all third-level headings in your emails.
	@style heading 3
	*/
		h3,.h3{
			/*@editable*/color:#202020;
			/*@editable*/display:block;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:26px;
			/*@editable*/font-weight:bold;
			/*@editable*/line-height:100%;
			/*@editable*/margin-top:0 !important;
			/*@editable*/margin-right:0 !important;
			/*@editable*/margin-bottom:10px !important;
			/*@editable*/margin-left:0 !important;
			/*@editable*/text-align:left;
		}
	/*
	@tab Page
	@section heading 4
	@tip Set the styling for all fourth-level headings in your emails. These should be the smallest of your headings.
	@style heading 4
	*/
		h4,.h4{
			/*@editable*/color:#202020;
			/*@editable*/display:block;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:18px;
			/*@editable*/font-weight:bold;
			/*@editable*/line-height:100%;
			/*@editable*/margin-top:0 !important;
			/*@editable*/margin-right:0 !important;
			/*@editable*/margin-bottom:10px !important;
			/*@editable*/margin-left:0 !important;
			/*@editable*/text-align:left;
		}
	/*
	@tab Header
	@section preheader style
	@tip Set the background color for your email's preheader area.
	@theme page
	*/
		#templatePreheader{
			/*@editable*/background-color:#FAFAFA;
		}
	/*
	@tab Header
	@section preheader text
	@tip Set the styling for your email's preheader text. Choose a size and color that is easy to read.
	*/
		.preheaderContent div{
			/*@editable*/color:#505050;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:10px;
			/*@editable*/line-height:100%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Header
	@section preheader link
	@tip Set the styling for your email's preheader links. Choose a color that helps them stand out from your text.
	*/
		.preheaderContent div a:link,.preheaderContent div a:visited,.preheaderContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@tab Header
	@section header style
	@tip Set the background color and border for your email's header area.
	@theme header
	*/
		#templateHeader{
			/*@editable*/background-color:#000000;
			/*@editable*/border-bottom:0;
			padding:0px;
		}
	/*
	@tab Header
	@section header text
	@tip Set the styling for your email's header text. Choose a size and color that is easy to read.
	*/
		.headerContent{
			/*@editable*/color:#202020;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:34px;
			/*@editable*/font-weight:bold;
			/*@editable*/line-height:100%;
			/*@editable*/padding:0;
			/*@editable*/text-align:center;
			/*@editable*/vertical-align:middle;
		}
	/*
	@tab Header
	@section header link
	@tip Set the styling for your email's header links. Choose a color that helps them stand out from your text.
	*/
		.headerContent a:link,.headerContent a:visited,.headerContent a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		#headerImage{
			/*@editable*/height:auto;
			/*@editable*/max-width:600px !important;
		}
	/*
	@tab Body
	@section body style
	@tip Set the background color for your email's body area.
	*/
		#templateContainer,.bodyContent{
			/*@editable*/background-color:#FFFFFF;
		}
	/*
	@tab Body
	@section body text
	@tip Set the styling for your email's main content text. Choose a size and color that is easy to read.
	@theme main
	*/
		.bodyContent div{
			/*@editable*/color:#505050;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:14px;
			/*@editable*/line-height:150%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Body
	@section body link
	@tip Set the styling for your email's main content links. Choose a color that helps them stand out from your text.
	*/
		.bodyContent div a:link,.bodyContent div a:visited,.bodyContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		.bodyContent img,.fullWidthBandContent img{
			/*@editable*/display:inline;
			/*@editable*/height:auto;
		}
	/*
	@tab Sidebar
	@section sidebar style
	@tip Set the background color and border for your email's sidebar area.
	*/
		#templateSidebar{
			/*@editable*/background-color:#FFFFFF;
		}
	/*
	@tab Sidebar
	@section sidebar text
	@tip Set the styling for your email's sidebar text. Choose a size and color that is easy to read.
	*/
		.sidebarContent div{
			/*@editable*/color:#505050;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:12px;
			/*@editable*/line-height:150%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Sidebar
	@section sidebar link
	@tip Set the styling for your email's sidebar links. Choose a color that helps them stand out from your text.
	*/
		.sidebarContent div a:link,.sidebarContent div a:visited,.sidebarContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		.sidebarContent img{
			/*@editable*/display:inline;
			/*@editable*/height:auto;
		}
	/*
	@tab Columns
	@section left column text
	@tip Set the styling for your email's left column text. Choose a size and color that is easy to read.
	*/
		.leftColumnContent{
			/*@editable*/background-color:#FFFFFF;
		}
	/*
	@tab Columns
	@section left column text
	@tip Set the styling for your email's left column text. Choose a size and color that is easy to read.
	*/
		.leftColumnContent div{
			/*@editable*/color:#505050;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:14px;
			/*@editable*/line-height:150%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Columns
	@section left column link
	@tip Set the styling for your email's left column links. Choose a color that helps them stand out from your text.
	*/
		.leftColumnContent div a:link,.leftColumnContent div a:visited,.leftColumnContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		.leftColumnContent img{
			/*@editable*/display:inline;
			/*@editable*/height:auto;
		}
	/*
	@tab Columns
	@section right column text
	@tip Set the styling for your email's right column text. Choose a size and color that is easy to read.
	*/
		.rightColumnContent{
			/*@editable*/background-color:#FFFFFF;
		}
	/*
	@tab Columns
	@section right column text
	@tip Set the styling for your email's right column text. Choose a size and color that is easy to read.
	*/
		.rightColumnContent div{
			/*@editable*/color:#505050;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:14px;
			/*@editable*/line-height:150%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Columns
	@section right column link
	@tip Set the styling for your email's right column links. Choose a color that helps them stand out from your text.
	*/
		.rightColumnContent div a:link,.rightColumnContent div a:visited,.rightColumnContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		.rightColumnContent img{
			/*@editable*/display:inline;
			/*@editable*/height:auto;
		}
	/*
	@tab Footer
	@section footer style
	@tip Set the background color and top border for your email's footer area.
	@theme footer
	*/
		#templateFooter{
			/*@editable*/background-color:#FFFFFF;
			/*@editable*/border-top:0;
		}
	/*
	@tab Footer
	@section footer text
	@tip Set the styling for your email's footer text. Choose a size and color that is easy to read.
	@theme footer
	*/
		.footerContent div{
			/*@editable*/color:#707070;
			/*@editable*/font-family:Arial;
			/*@editable*/font-size:12px;
			/*@editable*/line-height:125%;
			/*@editable*/text-align:left;
		}
	/*
	@tab Footer
	@section footer link
	@tip Set the styling for your email's footer links. Choose a color that helps them stand out from your text.
	*/
		.footerContent div a:link,.footerContent div a:visited,.footerContent div a .yshortcuts {
			/*@editable*/color:#336699;
			/*@editable*/font-weight:normal;
			/*@editable*/text-decoration:underline;
		}
	/*
	@editable
	*/
		.footerContent img{
			/*@editable*/display:inline;
		}
	/*
	@tab Footer
	@section social bar style
	@tip Set the background color and border for your email's footer social bar.
	@theme footer
	*/
		#social{
			/*@editable*/background-color:#FAFAFA;
			/*@editable*/border:0;
		}
	/*
	@tab Footer
	@section social bar style
	@tip Set the background color and border for your email's footer social bar.
	*/
		#social div{
			/*@editable*/text-align:center;
		}
	/*
	@tab Footer
	@section utility bar style
	@tip Set the background color and border for your email's footer utility bar.
	@theme footer
	*/
		#utility{
			/*@editable*/background-color:#FFFFFF;
			/*@editable*/border:0;
		}
	/*
	@tab Footer
	@section utility bar style
	@tip Set the background color and border for your email's footer utility bar.
	*/
		#utility div{
			/*@editable*/text-align:center;
		}
	/*
	@editable
	*/
		#monkeyRewards img{
			/*@editable*/max-width:190px;
		}
		body,#backgroundTable{
			background-color:#27043e;
		}
</style></head>
    <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
    	<center>
        	<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="backgroundTable">
            	<tr>
                	<td align="center" valign="top">
                        <!-- ******************************** -->
                        <!-- ******* START OF PREHEADER ***** -->
                        <!-- ******************************** -->
                        <table border="0" cellpadding="10" cellspacing="0" width="600" id="templatePreheader">
                            <tr>
                                <td valign="top" class="preheaderContent">
                                	
                                	<!-- // Begin Module: Standard Preheader \ -->
                                    <table border="0" cellpadding="10" cellspacing="0" width="100%">
                                    	<tr>
                                        	<td valign="top">
                                            	<div mc:edit="std_preheader_content"><br></div>
                                            </td>

											<td valign="top" width="400">
                                            	<div mc:edit="std_preheader_links">
                                                	Is this email not displaying correctly? <a href="http://www.ibreastfeeding.com/current-newsletter" target="_blank">View it in your browser</a>.
                                                </div>
                                            </td>

                                        </tr>
                                    </table>
                                	<!-- // End Module: Standard Preheader \ -->
                                
                                </td>
                            </tr>
                        </table>
                        <!-- ******************************** -->
						<!-- ******* END OF PREHEADER ******* -->
						<!-- ******************************** -->
                    	<table border="0" cellpadding="0" cellspacing="0" width="600" id="templateContainer">
                        	<tr>
                            	<td align="center" valign="top">
                                    <!-- // Begin Template Header \\ -->
                                	<table border="0" cellpadding="0" cellspacing="0" width="600" id="templateHeader">
                                        <tr>
                                            <td class="headerContent">
                                            
                                            	<!-- // Begin Module: Standard Header Image \\ -->
                                            	<img src="http://gallery.mailchimp.com/5e4d40d856375b24a209ec770/images/image_13328619380941332861937.jpg" style="max-width:600px;" id="headerImage campaign-icon" mc:label="header_image" mc:edit="header_image" mc:allowdesigner mc:allowtext>
                                            	<!-- // End Module: Standard Header Image \\ -->
                                            
                                            </td>
                                        </tr>
                                    </table>
                                    <!-- // End Template Header \\ -->
                                </td>
                            </tr>
                        	<tr>
                            	<td align="center" valign="top">
                                    <!-- // Begin Template Body \\ -->
                                	<table border="0" cellpadding="0" cellspacing="0" width="600" id="templateBody">
                                    	<tr>
                                            <!-- // Begin Sidebar \\ -->
                                        	<td valign="top" width="140" id="templateSidebar">
                                            	<table border="0" cellpadding="0" cellspacing="0" width="140">
                                                	<tr>
                                                    	<td valign="top" class="sidebarContent">
                                                        
                                                            <!-- // Begin Module: Content above social block \\ -->
                                                            <table border="0" cellpadding="10" cellspacing="0" width="100%">
                                                                <tr mc:repeatable>
                                                                    <td valign="top">
                                                                        <div mc:edit="tiwc200_content00">
			 	                                                            <h5 class="h4">In this Issue</h4>
			                                                                <ul alignt="left">
			                                                                	<li>News Item 1</li>
			                                                                	<li>News Item 2</li>
			                                                                	<li>News Item 3</li>
			                                                                	<li>News Item 4</li>
			                                                                	<li>News Item 5</li>
			                                                                	<li>News Item 6</li>
			                                                                	<li>News Item 7</li>
			                                                                </ul>
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                            <!-- // End Module: Content above social block \\ -->

                                                            <!-- // Begin Module: Social Block with Icons \\ -->
                                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                                <tr>
                                                                    <td valign="top" style="padding-top:20px; padding-right:20px; padding-left:20px;">
                                                                        <table border="0" cellpadding="0" cellspacing="4">
                                                                            <tr mchideable="hideable_1">
                                                                                <td align="left" valign="middle" width="16">
                                                                                    <img src="http://gallery.mailchimp.com/653153ae841fd11de66ad181a/images/sfs_icon_facebook.png" style="margin:0 !important;">
                                                                                </td>
                                                                                <td align="left" valign="top">
                                                                                    <div mc:edit="sbwi_link_one">
                                                                                        <a href="*|FACEBOOK:PROFILEURL|*">Friend on Facebook</a>
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr mchideable="hideable_2">
                                                                                <td align="left" valign="middle" width="16">
                                                                                    <img src="http://gallery.mailchimp.com/653153ae841fd11de66ad181a/images/sfs_icon_twitter.png" style="margin:0 !important;">
                                                                                </td>
                                                                                <td align="left" valign="top">
                                                                                    <div mc:edit="sbwi_link_two">
                                                                                        <a href="*|TWITTER:PROFILEURL|*">Follow on Twitter</a>
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr mchideable="hideable_3">
                                                                                <td align="left" valign="middle" width="16">
                                                                                    <img src="http://gallery.mailchimp.com/653153ae841fd11de66ad181a/images/sfs_icon_forward.png" style="margin:0 !important;">
                                                                                </td>
                                                                                <td align="left" valign="top">
                                                                                    <div mc:edit="sbwi_link_three">
                                                                                        <a href="*|FORWARD|*">Forward to a Friend</a>
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                            <!-- // End Module: Social Block with Icons \\ -->
                                                        
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                            <!-- // End Sidebar \\ -->
                                        	<td valign="top" width="400">
                                            	<table border="0" cellpadding="0" cellspacing="0" width="400">
                                                	<tr>
                                                    	<td valign="top">
                                            				<table border="0" cellpadding="0" cellspacing="0" width="400">
                                                            	<tr>
                                                                	<td valign="top" class="bodyContent">
                                                            
                                                            			<!-- ******************************** -->
                                                                        <!-- // BEGIN TOP CONTENT \\ -->
                                                                        <!-- ******************************** -->
                                                                        <table border="0" cellpadding="10" cellspacing="0" width="100%">
                                                                            <tr>
                                                                                <td valign="top">
						                                                            <div mc:edit="std_content00">
						                                                                <h1 class="h1">Month Year Newsletter</h1>
						                                                                <strong>Introductory Text:</strong> Custom intro text here; typically done before any of the news articles in the newsletter.
						                                                                <br>
						                                                            </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                            	<td align="center">
                                                                            		<img src="http://media.ibreastfeeding.com/images/separator.jpg" class="separator-img" alt="separator">
                                                                            	</td>
                                                                            </tr>
                                                                        </table>
                                                                        <!-- ******************************** -->
                                                                        <!-- // END OF TOP CONTENT\\ -->
                                                                        <!-- ******************************** -->
                                                            
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                		</td>
                                                    </tr>
                                                    <tr>
                                                    	<td valign="top">
                                                            <table border="0" cellpadding="0" cellspacing="0" width="400">
                                                                <tr>
                                                                    <td valign="top" width="180" class="leftColumnContent">
                                                                    
                                                                    	<!-- ******************************** -->
                                                                        <!-- // BEGIN LEFT COLUMN CONTENT \\ -->
                                                                        <!-- ******************************** -->
                                                                        <table border="0" cellpadding="5" cellspacing="0" width="100%">
                                                                            <tr mc:repeatable>
                                                                                <td valign="top">
                                                                                    <div mc:edit="tiwc200_content01">
						 	                                                            <h4 class="h4">News Item</h4>
						                                                                <strong>Teaser:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras facilisis molestie interdum. Etiam nec urna dolor. Integer pellentesque sagittis odio, sit amet facilisis est blandit non. Praesent blandit pharetra ipsum, in congue dolor accumsan quis. 
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                				<td align="center">
                                                                   					<img src="http://www.ibreastfeeding.com/sites/default/files/images/separator.jpg" class="separator-img" alt="separator">
                                                                    			</td>
                                                                			</tr> 
                                                                			<tr mc:repeatable>
                                                                                <td valign="top">
                                                                                    <div mc:edit="tiwc200_content03">
						 	                                                            <h4 class="h4">News Item</h4>
						                                                                <strong>Teaser:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras facilisis molestie interdum. Etiam nec urna dolor. Integer pellentesque sagittis odio, sit amet facilisis est blandit non. Praesent blandit pharetra ipsum, in congue dolor accumsan quis. 
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                				<td align="center">
                                                                   					<img src="http://www.ibreastfeeding.com/sites/default/files/images/separator.jpg" class="separator-img" alt="separator">
                                                                    			</td>
                                                                			</tr> 
                                                                            <tr mc:repeatable>
                                                                                <td valign="top">
                                                                                    <div mc:edit="tiwc200_content03">
						 	                                                            <h4 class="h4">News Item</h4>
						                                                                <strong>Teaser:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras facilisis molestie interdum. Etiam nec urna dolor. Integer pellentesque sagittis odio, sit amet facilisis est blandit non. Praesent blandit pharetra ipsum, in congue dolor accumsan quis. 
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                        <!-- ******************************** -->
                                                                        <!-- // END OF LEFT COLUMN CONTENT \\ -->
                                                                        <!-- ******************************** -->
                                                                    </td>
                                                                    <td valign="top" width="180" class="rightColumnContent">
                                                                    
                                                                    	<!-- ******************************** -->
                                                                        <!-- // BEGIN RIGHT COLUMN CONTENT \\ -->
                                                                        <!-- ******************************** -->
                                                                        <table border="0" cellpadding="5" cellspacing="0" width="100%">
                                                                            <tr mc:repeatable>
                                                                                <td valign="top">
                                                                                    <div mc:edit="tiwc200_content02">
 						 	                                                            <h4 class="h4">News Item</h4>
						                                                                <strong>Teaser:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras facilisis molestie interdum. Etiam nec urna dolor. Integer pellentesque sagittis odio, sit amet facilisis est blandit non. Praesent blandit pharetra ipsum, in congue dolor accumsan quis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                                                                                    </div>
                                                                                </td>

                                                                            </tr>

                                                                            <tr>
                                                                				<td align="center">
                                                                   					<img src="http://www.ibreastfeeding.com/sites/default/files/images/separator.jpg" class="separator-img" alt="separator">
                                                                    			</td>
                                                                			</tr> 

                                                                            <tr mc:repeatable>
                                                                                <td valign="top">
                                                                                    <div mc:edit="tiwc200_content02">
 						 	                                                            <h4 class="h4">News Item</h4>
						                                                                <strong>Teaser:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras facilisis molestie interdum. Etiam nec urna dolor. Integer pellentesque sagittis odio, sit amet facilisis est blandit non. Praesent blandit pharetra ipsum, in congue dolor accumsan quis. 
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                				<td align="center">
                                                                   					<img src="http://www.ibreastfeeding.com/sites/default/files/images/separator.jpg" class="separator-img" alt="separator">
                                                                    			</td>
                                                                			</tr> 
                                                                        </table>
                                                                        <!-- ******************************** -->
                                                                        <!-- // END OF RIGHT COLUMN CONTENT \\ -->
                                                                        <!-- ******************************** -->
                                                                                                                                            
                                                                    </td>

                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>                                                
                                            </td>
                                        </tr>
                                    </table>
                                    <!-- // End Template Body \\ -->
                                </td>
                            </tr>
                        	<tr>
                            	<td align="center" valign="top">
                                    <!-- // Begin Template Footer \\ -->
                                	<table border="0" cellpadding="10" cellspacing="0" width="600" id="templateFooter">
                                    	<tr>
                                        	<td valign="top" class="footerContent">
                                            
                                                <!-- // Begin Module: Standard Footer \\ -->
                                                <table border="0" cellpadding="10" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td colspan="2" valign="middle" id="social">
                                                            <div mc:edit="std_social">
                                                                &nbsp;<a href="*|TWITTER:PROFILEURL|*">Follow on Twitter</a> | <a href="*|FACEBOOK:PROFILEURL|*">Friend on Facebook</a> | <a href="*|FORWARD|*">Forward to a friend</a>&nbsp;
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td valign="top" width="350">
                                                            <div mc:edit="std_footer">
																<!--<em>Copyright &copy; *|CURRENT_YEAR|* *|LIST:COMPANY|*, All rights reserved.</em> -->

																<strong>
																Hale Publishing, L.P.<br>
																1712 N. Forest St.<br>
																Amarillo, TX 79106<br>
																</strong>
                                                            </div>
                                                        </td>
                                                        <td valign="top" width="190" id="monkeyRewards">
                                                            <div mc:edit="monkeyrewards">
                                                                <strong>
                                                                	Toll Free: 800-378-1317
                                                                	Phone: 806-376-9900
                                                                	Fax: 806-376-9901
                                                                	Books@halepublishing.com
                                                                </strong>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2" valign="middle" id="utility">
                                                            <div mc:edit="std_utility">
                                                                &nbsp;<a href="*|UNSUB|*">Unsubscribe from this list</a>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <!-- // End Module: Standard Footer \\ -->
                                            
                                            </td>
                                        </tr>
                                    </table>
                                    <!-- // End Template Footer \\ -->
                                </td>
                            </tr>
                        </table>
                        <br>
                    </td>
                </tr>
            </table>
        </center>
    </body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: Generating HTML with php for email newsletter

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,884
  • Joined: 08-August 08

Re: Generating HTML with php for email newsletter

Posted 27 March 2012 - 03:15 PM

Use PHP to read in your HTML file and make changes to it before sending.
Was This Post Helpful? 0
  • +
  • -

#3 JonQCoder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 44
  • Joined: 23-May 11

Re: Generating HTML with php for email newsletter

Posted 28 March 2012 - 05:58 AM

Wow, lol. This looks exactly like what I need. Thank you! I will give it a try :D If I have problems, should I post here, in that topic or just create a new topic?
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,884
  • Joined: 08-August 08

Re: Generating HTML with php for email newsletter

Posted 28 March 2012 - 06:06 AM

Since it's related post it in this one.
Was This Post Helpful? 0
  • +
  • -

#5 JonQCoder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 44
  • Joined: 23-May 11

Re: Generating HTML with php for email newsletter

Posted 28 March 2012 - 02:52 PM

Ran into a little problem finding the correct data, but got that worked out. Now my issue is how to take what the other thread showed me, and implement it with this giant html file. Here is what i've implemented so far to get the data from the database.
$result = mysql_query("SELECT node_revisions.title, node_revisions.teaser FROM node_revisions
                       JOIN node ON node_revisions.nid = node.nid
                       JOIN term_node ON node.nid = term_node.nid
                       JOIN term_data ON term_node.tid = term_data.tid
                       WHERE term_data.name = 'March 2012'
                       ORDER BY node.created DESC");

while($info = mysql_fetch_array($result)) {

  echo $info['title'] . "\n";
  echo $info['teaser'] . "\n";
}



The actual content of newsletter is separated into left and right columns. The number of articles won't be the same for each newsletter(I'm assuming this) but it will never be more than 6 or 7. What I had in mind was using a counter initialized to 1 and if the number is odd, place the data in the left, and if it's even, put it in the right column. In the newsletter template, I would put something to indicate which column it is and handle the code to be inserted, in the script. This is an example of what i'm thinking of doing:

$column = 1;
while($info = mysql_fetch_array($result)) {

//If column is an odd number
	if( $odd = $column%2 )
	{
		Insert echo $info['title'] and echo $info['teaser']into the left column
	}
	else 
	{
		Insert echo $info['title'] and echo $info['teaser']into the right column
	}

	$column++;
}



Now in the newsletter.html file I would have <!-- L1 -->, <!-- L3 -->, <!-- L5 --> for the left side and <!-- R2 -->, <!-- R4 -->, <!-- R6 --> for the right. And in the code above I would replace the <!-- L1 --> or <!-- R2 --> etc in the file with the code for the news info. I'd use <!-- L . $column . --> so that it's in the right place. Similar to how it was done in the other thread with the "PHPTITLE", "PHPSOMEBODY", "PHPFOOTER", "PHPCSS"

I'm not sure how efficient this would be, but it's the only way I can think of at the moment. Thanks in advance.

Edit:
If you want to know what type of information/how much will be going into it, you can look here:
Link to web newsletter

This post has been edited by JonQCoder: 28 March 2012 - 02:56 PM

Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,884
  • Joined: 08-August 08

Re: Generating HTML with php for email newsletter

Posted 28 March 2012 - 04:27 PM

I would have something like this:
$column = 0;
$columndata = array("","");
while($info = mysql_fetch_array($result)) {
	$columndata[$column] .= $info['title']."<br>".$info['teaser'];
	if(strlen($columndata[0]) > $some_arbitrary_value) {
		$column = 1;
	}
}

$output = str_replace(array("{leftcontent}", "{rightcontent}"), $columndata, file_get_contents("newslettertemplate.html"));

echo $output;


newslettertemplate.html:
<html headers etc....
<div class="LeftColumn">{leftcontent}</div>
<div class="RightColumn">{rightcontent}</div>
...footers...

It's not complete, or tested, but hopefully you'll get the idea.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1