Jump to content

Trying to reproduce the same table on outlook as in gmail


Recommended Posts

Hello,

I almost over my first PHP script, but I don't understand where I'm wrong.

This is my script:

<?php
	
	$data=array();
	$temp=array("Request_SI_legacy"=>0,"Request_ReqID_legacy"=>0,"Fault_SI_legacy"=>0,"Fault_FLT_legacy"=>0,);	
	
	function Executequery_legacy($q,$type)
	{
		global $data;
		global $conn;
		global $temp;
		$resultset=$conn->query($q);
		if(!$resultset)
		{
			TRACE("Errore esecuzione query $type :" . $conn->errorMsg); 
			die();
		}
			
		while($row_object=$conn->fetch($resultset))
		{
			(!isset($data[$row_object['Server']]))?$data[$row_object['Server']]=$temp:'';
			$data[$row_object['Server']][$type]=(($row_object['value']!="")?$row_object['value']:'');
		}
	}
	
	//COSTRUZIONE TABELLA PER AMBIENTE .NET intranet Legacy
	
	function create_table_legacy()
	{
		global $data;
		$keys=array_keys($data);
		
		$styleTB="style='font-family:arial;background-color:#1a0da8;margin:3px 0pt 15px;font-size: 9pt;width: 100%;text-align: center;'";
		$styleTHfirst="style='font-family:arial;color:#f7fafa;background-color:#1a0da8;border:1px solid #FFF;padding:4px;font-size:18px;font-weight:bold;'";
		$styleTHsecond="style='background-color:#d5eded;border:1px solid #FFF;padding:4px;font-size:15px;font-weight:bold;font-style:italic;'";
		$styleTD="style='color:#3D3D3D;padding:4px;background-color:#FFF;vertical-align:top;'";
		
		
		$rowTable_legacy="";
		
		
		foreach($keys as $key)
		{	
			$_Request_SI_legacy=$data[$key]['Request_SI_legacy'];
			$_Request_ReqID_legacy=$data[$key]['Request_ReqID_legacy'];			
			$scostRequest_legacy=$_Request_SI_legacy-$_Request_ReqID_legacy;
			
			//$scostRequestPerc=(($_Request_SI==0 && $_Request_ReqID==0)?"Nessuno":(($_Request_SI==0)?"100 %":number_format((($scostRequest/$_Request_SI)*100),2)." %"));
			
			$_Fault_SI_legacy=$data[$key]['Fault_SI_legacy'];
			$_Fault_FLT_legacy=$data[$key]['Fault_FLT_legacy'];
			$scostFault_legacy=$_Fault_SI_legacy-$_Fault_FLT_legacy;
			
			//$scostFaultPerc=(($_Fault_FLT==0 && $_Fault_SI==0)?"Nessuno":(($_Fault_SI==0)?"100 %":number_format((($scostFault/$_Fault_SI)*100),2)." %"));
			
			$rowTable_legacy.="<tr>
								<td $styleTD align=center >
									<b>$key</b>
								</td>
								<td $styleTD align=center >
									".number_format($_Request_SI_legacy,0,',','.')."
								</td>
								<td $styleTD align=center >
									".number_format($_Request_ReqID_legacy,0,',','.')."
								</td>
								<td $styleTD align=center>
									".number_format($scostRequest_legacy,0,',','.')."
								</td>
								<td $styleTD align=center >
									".number_format($_Fault_SI_legacy,0,',','.')."
								</td>
								<td $styleTD align=center >
									".number_format($_Fault_FLT_legacy,0,',','.')."
								</td>
								<td $styleTD align=center >
									".number_format($scostFault_legacy,0,',','.')."
								</td>
							</tr>";						
		}
		
		$table_confronti_legacy="<table $styleTB id='table_confronti_legacy' style='width:100%'>
		                   	<thead>
								<th $styleTHfirst colspan=7  align=center >
								Ambiente .NET intranet Legacy
								</th>
							</thead>
							<tbody>
								<tr>
									<td $styleTHsecond align=center>
										Server
									</td>
									<td $styleTHsecond align=center >
										Request su SI
									</td>
									<td $styleTHsecond align=center >
										Request su SI_ReqID 
									</td>
									<td $styleTHsecond align=center >
										 Δ request
									<td $styleTHsecond align=center>
										Fault su SI
									</td>
									<td $styleTHsecond align=center >
										Fault su FLT 
									</td>
									<td $styleTHsecond align=center >
										Δ fault
									</td>								
								</tr>
								$rowTable_legacy
							</tbody>
						</table>";
									
		
		$tb_legacy="	<center>
					<table style='width:100%'>
						<tr>
							<td>
								<div >".$table_confronti_legacy."</div>
							</td>
						</tr>
					</table>
				</center>";
				
		return 	$tb_legacy;	
	}
	
	
	$yesterday_inf_sol= "1".substr(date('Ymd',strtotime("-2 days")),2)."230000000";
	$yesterday_sup_sol= "1".substr(date('Ymd',strtotime("-1 days")),2)."230000000";
	$yesterday_inf_leg= "1".substr(date('Ymd',strtotime("-2 days")),2)."220000000";
	$yesterday_sup_leg= "1".substr(date('Ymd',strtotime("-1 days")),2)."220000000";
	
	
	$query_SI_request_legacy='select 
								    upper(substr("Origin_Node",13,10)) as "Server",
									sum("Request_Count") as "value"
								from 
									"Services_Inventory_610"
								where 
									upper(substr("Origin_Node",13,9))=\'WEBINPS12\' and "Service_Type"=1 and 
									CASE
									   WHEN "TMZDIFF"=\'-3600\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_sol.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_sol.'\')
									   WHEN "TMZDIFF"=\'-7200\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_leg.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_leg.'\')
									END
									group by upper(substr("Origin_Node",13,10))';
	
		
	$query_ReqID_legacy='select 
								upper(substr("Origin_Node",13,10)) as "Server",
								sum("Request_Count") as "value" 
							from 
								"Services_Inventory_ReqID_610"
							where 
								upper(substr("Origin_Node",13,9))=\'WEBINPS12\' and
								CASE
									   WHEN "TMZDIFF"=\'-3600\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_sol.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_sol.'\')
									   WHEN "TMZDIFF"=\'-7200\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_leg.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_leg.'\')
								END
							 	group by upper(substr("Origin_Node",13,10))';
    							
		
	$query_SI_fault_legacy='select 
								sum("Fault_Count") as "value", 
								upper(substr("Origin_Node",13,10)) as "Server"
							   from 
								"Services_Inventory_610"
							where upper(substr("Origin_Node",13,9))=\'WEBINPS12\' and
								CASE
									   WHEN "TMZDIFF"=\'-3600\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_sol.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_sol.'\')
									   WHEN "TMZDIFF"=\'-7200\' THEN  ("Interval_Begin_Time">=\''.$yesterday_inf_leg.'\' and "Interval_Begin_Time"<\''.$yesterday_sup_leg.'\')
								END
							group by upper(substr("Origin_Node",13,10)) ';
							
							
	$query_FLT_legacy='select 
								count(*) as "value", 
								upper(substr("Origin_Node",13,10)) as "Server"
							from
								"Fault_Log_Table_610"
							where upper(substr("Origin_Node",13,9))=\'WEBINPS12\' and
								CASE
									   WHEN "TMZDIFF"=\'-3600\' THEN  ("Message_Time">=\''.$yesterday_inf_sol.'\' and "Message_Time"<\''.$yesterday_sup_sol.'\')
									   WHEN "TMZDIFF"=\'-7200\' THEN  ("Message_Time">=\''.$yesterday_inf_leg.'\' and "Message_Time"<\''.$yesterday_sup_leg.'\')
								END
							group by upper(substr("Origin_Node",13,10)) ';
							
							
	Executequery_legacy($query_SI_request_legacy,'Request_SI_legacy');
	Executequery_legacy($query_ReqID_legacy,'Request_ReqID_legacy');
	
	Executequery_legacy($query_SI_fault_legacy,'Fault_SI_legacy');
	Executequery_legacy($query_FLT_legacy,'Fault_FLT_legacy');
	
	
	$result_legacy=create_table_legacy();
	
?>

I have another script which recalls the one above and send an email.

As long as I send the email to gmail, I have the table I want as you can see in the first image.

When I started to send the email to an outlook address, I get the table formatted as reported in the second image, that is the little blue borders between the cells and the nice effects white/blue border around the main title (I beg your pardon ... "Ambiente" in italian means Environment).

I tried everything into the variables in which I declared the various styles I use in the script, but nothing resolve.

PS: the identical same script I use to send the different emails, towards gmail and towards to outlook.

Further I'd like to use statical dimensions for tables (I will have to add another tables and I don't like they'll have different dimensions due to "width: 100%" options) 

Table as I want in gmail.JPG

Table as I get.JPG

I'm gonna guess that it is your way of styling the table elements.  Add some CSS to your output and stop using old formats for styling.  One mail system may not be honoring the way you are trying to style your tables.  You are using some out-dated ways of doing things.  Do your styling on the tags instead of each element of your table.  AND - are you sending the emails with html formatting enabled?

HTML in emails are notoriously - and I cannot stress that enough - inconsistent between clients. My advice is to ignore these sorts of minor differences.

That said, I don't see a border-collapse in there...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.