I am doing a webpage using HTML and PHP. Below, I attach a picture of my problem.
My first problem is that I cannot give the format I want to the table:
I'd like to adjust to the content columns 1, 2, 3 and 4.
Column 5 (last column) should have the more space the better.
The aaaaaaaaaaaaaaaa of the last column should not go beyond the table. It should be split up or with a line break when reach the column end.
Here a piece of my code:
echo "<table><tr>";
echo '<td width="40">ID</th>';
echo '<td width="50">Organism</th>';
echo '<td width="50">Chromosome</th>';
echo '<td width="50">Gene name</th>';
echo '<td>Sequence</th>';
echo "</tr>";
while($row = mysqli_fetch_array($result2)) {
echo "<tr>";
echo "<td>$row[id_send]</td>";
echo "<td>$row[organism]</td>";
echo "<td>$row[chromosome]</td>";
echo "<td>$row[gene]<br></td>";
echo "<td>$row[sequence]</td>";
echo "</tr>";
}
echo "</table>";
You can use this css for the table.
.wrapText
{
table-layout:fixed;
width: 100%;
word-wrap: break-word;
}
However "break-word" will break the words and wrap them into the next line, it could make the text unreadable.
.table {
margin-bottom: 30px;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
.tableHeading {
font-size: 18px;
font-weight: bold;
text-transform: capitalize;
color: #000000;
padding: 5px;
background: url('/images/table-2-head-bg.gif');
background-repeat: repeat-x;
background-color: #f7f7f7;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableSubHeading {
padding: 5px;
color: #666666;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableMassActionCell {
padding-top: 10px;
padding-left: 10px;
font-size: 12px;
font-weight: bold;
background-color: #f7f7f7;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableColumnHeader {
font-weight: bold;
font-size: 12px;
background-color: #EEEEEE;
padding: 5px;
border-top: 2px solid #fff;
border-left: 2px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableRowNoResults {
font-weight: bold;
background-color: #ffccff;
text-align: center;
padding: 10px;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableRowLeft1 {
font-weight: bold;
background-color: #f7f7f7;
padding: 5px;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableRowRight1 {
padding: 5px;
background-color: #f7f7f7;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableRowLeft2 {
font-weight: bold;
background-color: #ffffff;
padding: 5px;
border-top: 1px solid #eee;
border-left: 1px solid #eee;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableRowRight2 {
padding: 5px;
background-color: #ffffff;
border-top: 1px solid #eee;
border-left: 1px solid #eee;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.tableSubmitCell {
background-color: #EEEEEE;
padding: 5px;
border-top: 2px solid #fff;
border-left: 2px solid #fff;
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
text-align: right;
}
Related
I want PDF separate html(invoice.html) page using DomPDF library,
but when I generating html file to PDF its throwing error like: it would throwing error regarding style sheet.
'DOMXPath::query(): Invalid expression' (length=37)
D:\wamp\www\crm\include\dompdf\src\Css\Stylesheet.php:882:string
html file:-
1)invoice.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Invoice</title>
</head>
<body style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;">
<div style="width: 680px;">
<table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
<tr>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: left; padding: 7px; color: #222222;" colspan="2">Order Details</td>
</tr>
<tr>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
<b>Invoice Id</b> {{invoice_id}}<br />
<b>Date</b> {{date}}<br />
<b>Payment</b> {{payment_method}}<br />
</td>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
<b>Address</b> {{store_address}}<br />
<b>Telephone</b> {{store_telephone}}<br />
<b>GSTIN</b> {{store_gstin}}<br />
</td>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
<tr>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: left; padding: 7px; color: #222222;" colspan="3">Customer Details</td>
</tr>
<tr>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
<b>GSTIN</b> {{customer_gstin}}<br />
<b>Telephone</b> {{customer_number}}<br />
<b>Address</b> {{customer_address}}<br />
</td>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
<thead>
<tr>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: left; padding: 7px; color: #222222;">Product</td>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: right; padding: 7px; color: #222222;">Quantity</td>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: right; padding: 7px; color: #222222;">Price</td>
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: right; padding: 7px; color: #222222;">Total</td>
</tr>
</thead>
<tbody>
{{products}}
</tbody>
<tfoot>
{{totals}}
</tfoot>
</table>
</div>
</body>
</html>
controller:-
2)sales.php(codeigniter controller)
$dompdf = new dompdf();
$sourcefile = file_get_contents(webpath.'include/invoice.html');
$original = array("{{invoice_id}}","{{date}}","{{payment_method}}","{{store_address}}","{{store_telephone}}","{{store_gstin}}","{{customer_gstin}}","{{customer_number}}","{{customer_address}}","{{products}}","{{totals}}");
$replace = array($invoice_id,$date,ucfirst($datas['payConition']),$storedata['store_address'],$storedata['store_telephone'],$storedata['store_gstIn'],$users['party_gstin'],$users['party_number'],$users['party_address'],$producttext,$totaltext);
$printfile = str_replace($original, $replace, $sourcefile);
$dompdf->loadHtml($printfile);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
//$d
I have a php script that create a table with custom color as background,
here is some part of the code:
foreach($cells as $cell) {
$html .= "<td style='width:".$cell['width']."%; height: 20px ; border:1px solid black ; background-color:" . $cell['color'] . "' > </td>";
}
but when the email is generated i got this:
<TR>
...
<TD style="BORDER-TOP: black 1px solid; HEIGHT: 20px; BORDER-RIGHT: black 1px solid; WIDTH: 0.15%; BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: #dbdbdb"></TD>
<TD style="BORDER-TOP: black 1px solid; HEIGHT: 20px; BORDER-RIGHT: black 1px solid; WIDTH: 0.15%; BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: orange"></TD>
<TD ?width:0.15%;height:20px;border:1pxsolidblack;background-color:Green?=""></TD>
<TD style="BORDER-TOP: black 1px solid; HEIGHT: 20px; BORDER-RIGHT: black 1px solid; WIDTH: 0.15%; BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: green"></TD>
...
</TR>
I have absolutely no idea where the '?' come from and no idea how to fix it.
EDIT: added ; at the end of the line fix it.
$html .= "<td style='width:".$cell['width']."%; height: 20px ; border:1px solid black ; background-color:" . $cell['color'] . ";' > </td>";
I've been searching everywhere, how to make a html/css resonsive S shaped dotted line like this
So, far it has been the bain of my existence.
I'm trying to avoid SVG at all costs, althought i've also searched how to do it in SVG.
Can someone help me?
hr.style-seven {
height: 150px;
border-style: solid;
border-color: black;
border-width: 1px 0 0 0;
border-radius: 130px 0px 0px 0px;
border-top: 1px dashed #8c8c8c;
margin-right:130px;
}
hr.style-seven:before {
display: block;
content: "";
height: 150px;
margin-top: -151px;
border-style: solid;
border-color: black;
border-width: 0 0 1px 0;
border-radius: 0px 0px 130px 0px;
margin-left:130px;
margin-right:-130px;
border-bottom: 1px dashed #8c8c8c;
}
.box{ height: 500px; margin-top:200px;}
<body class="box">
<hr class="style-seven"/>
</body>
Demo
I am writing a code that will take a user reply to an automated message and parse out any previous discussion. then take the body of the new email and insert it into a database.
I thought I can add <!-- This is the message break --> to the very top of my message and from there I can remove anything under this phrase when reading the email. using something like this
$newReply = strstr($message, '<!-- This is the message break -->',true);
But for some reason the email server seems to be removing the page break that I added (ie. <!-- This is the message break -->) I can't find it in the email.
Here is the html code that I am using to send it as an email using php mail() function.
<!-- This is the message break -->
<html>
<body>
<table rules="all" style="padding: 10px; line-height: 1.42857143; vertical-align: Middle; border: 5px solid #1A1A1C; width: 780px; border-collapse: collapse; border-spacing: 0;" cellspacing="0">
<tr>
<td colspan="2" style="text-align: center; background-color: #1A1A1C; color: #fff; padding: 5px;">Need to respond? Just hit reply, a responses will be appended to ticket details automatically</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C; background-color: #F0F0F0;">Subject</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; background-color: #F0F0F0;">'.strip_tags($ticketInfo['title']).'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C;">Ticket #</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; ">'.$ticketInfo['issue_id'].'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C; background-color: #F0F0F0;">Notification</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; background-color: #F0F0F0;">'.$ticketInfo['notificationType'].'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C;">Status</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; ">'.$ticketInfo['ticketStatus'].'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C; background-color: #F0F0F0;">Priority</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; background-color: #F0F0F0;">'.$ticketInfo['priority']. ' - ' . $ticketInfo['ticket_type'] .'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C;">Ticket Assigned To</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; ">'.$ticketInfo['assigned_to'].'</td>
</tr>
<tr>
<td width="100" style="color: #333333; font-weight: bold; border-top: 1px solid #DBDBDB; border-right: 1px solid #DBDBDB; border-bottom: 1px solid #DBDBDB; border-left: 5px solid #1A1A1C; background-color: #F0F0F0;">Client Name</td>
<td style="color: #333333; border-top: 1px solid #DBDBDB; border-right: 5px solid #1A1A1C; border-bottom: 1px solid #DBDBDB; border-left: 1px solid #DBDBDB; background-color: #F0F0F0;">'.$ticketInfo['client_name'].'</td>
</tr>
<tr>
<td colspan="2">
'.$notes.'
<br /><br /><strong><em>To comment on this ticket, you can either replay directly to this email, or click the link below to view previous comments</em></strong><br />
<a href="'.$url .'"><em>Click Here To View This Ticket</em><a/><br /><br />
</td>
</tr>
</table>
</body></html>
I have made the following email template,
but instead of shown data in table format; it shows the complete Html codes in the email body. Please help me fix this.
<table style="font-family: Lucida Sans Unicode, Lucida Grande, Sans-Serif; font-size: 12px; background: #fff; margin: 45px; width: 480px; border-collapse: collapse; text-align: left;" summary="Website Uptime Statistics">
<thead>
<tr>
<th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">#S.No.</th>
<th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">Website</th>
<th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">1</td>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">http://google.com</td>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">Up</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">2</td>
<td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">http://google.com</td>
<td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">Down</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
<td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
</tr>
</tbody>
</table>
Have you set the content-type of the email so the receiving email application knows it contains HTML and can therefore present it properly?
Content-Type: text/html; charset=UTF-8
$html = '';
$html .= ' <table style="font-family: Lucida Sans Unicode, Lucida Grande, Sans-Serif; font-size: 12px; background: #fff; margin: 45px; width: 480px; border-collapse: collapse; text-align: left;" summary="Website Uptime Statistics"><thead>';
.....
echo $html;
try this