I'm not a PHP programmer so I'm asking for any help.
I try to send multiple attachments using PHPMailer function from a web form
When I select file or files and click on Send button I can receive email succesfully.
The problem is when I DO NOT SELECT any attachment. When I click on Send button and I do not add any attachment to my form I just get a blank web page - all my web form is not visible.
Can anybody help me and give any solution to my issue? Here is my code:
if(isset($_REQUEST['ownerName']) && (!empty($_REQUEST['ownerName']))){
$mail = new PHPMailer;
$mail->setFrom($ownerEmail);
$mail->addAddress($ownerEmail);
$mail->AddReplyTo($ownerEmail);
$mail->Subject = 'Ubezpieczenia podróży - zapytanie o oferte';
$mail->msgHTML("
<html><body>
<h2>DANE KLIENTA / DANE KONTAKTOWE:</h2>
<table style='border: 1px solid black;'>
<tr style='border: 1px solid black;'>
<th style='border: 1px solid black;'>Imie</th><th style='border: 1px solid
black;'>Nazwisko</th><th style='border: 1px solid black;'>PESEL</th><th style='border: 1px solid
black;'>Telefon</th ><th style='border: 1px solid black;'>Email</th>
</tr style='border: 1px solid black;'>
<tr style='border: 1px solid black;'>
<th style='border: 1px solid black;'>$ownerName</th><th style='border: 1px solid
black;'>$ownerSurname</th><th style='border: 1px solid black;'>$ownerPESEL</th><th style='border: 1px
solid black;'>$ownerPhoneNumber</th><th style='border: 1px solid black;'>$ownerEmail</th>
</tr>
</table>
<h2>DANE PODRÓŻY:</h2>
<table style='border: 1px solid black;'>
<tr style='border: 1px solid black;'>
<th style='border: 1px solid black;'>Strefa wyjazdu</th><th style='border: 1px solid
black;'>Liczba osób poniżej 26 lat</th><th style='border: 1px solid black;'>Liczba osób pomiędzy 26 a
65 lat</th><th style='border: 1px solid black;'>Liczba osób powyżej 65 lat</th><th style='border: 1px
solid black;'>Początek okresu ubezpieczenia</th><th style='border: 1px solid black;'>Koniec okresu
ubezpieczenia</th>
</tr>
<tr style='border: 1px solid black;'>
<th style='border: 1px solid black;'>$TripDirection</th><th style='border: 1px solid
black;'>$amountOfLess26</th><th style='border: 1px solid black;'>$amoountOfBetween26and65</th><th
style='border: 1px solid black;'>$amountOfMoreThan65</th><th style='border: 1px solid
black;'>$insuranceStartDate</th><th style='border: 1px solid black;'>$insuranceEndDate</th>
</tr>
<table>
</body></html>
");
foreach ($_FILES["attachment"]["name"] as $k => $v) {
$mail->AddAttachment( $_FILES["attachment"]["tmp_name"][$k], $_FILES["attachment"]["name"][$k] );
}
$mail->IsHTML(true);
$mail->CharSet = "UTF-8";
if(!$mail->send()){
echo "Błąd w trakcie wysyłania wiadomości: " . $mail->ErrorInfo;
}else{
echo "Dziękujęmy za wysłanie wiadomości!";
}
}
after few hours I found solution.
I needed to add
require_once("src/Exception.php");
And all email works good with and without attachments
Related
I´m using DomPDF to generate a PDF in PHP. I need to put 2 tables side by side.
<table style=" border: 1px solid black !important;">
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">names</td>
<td style=" border: 1px solid black !important;">salary</td>
</tr>
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Pedro</td>
<td style=" border: 1px solid black !important;">1500</td>
</tr>
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Jhon</td>
<td style=" border: 1px solid black !important;">450</td>
</tr>
</table>
<table style=" border: 1px solid black !important;">
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Brand</td>
<td style=" border: 1px solid black !important;">Color</td>
</tr>
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Ferrari</td>
<td style=" border: 1px solid black !important;">Green</td>
</tr>
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Daewoo</td>
<td style=" border: 1px solid black !important;">Blue</td>
</tr>
<tr style=" border: 1px solid black !important;">
<td style=" border: 1px solid black !important;">Chevrolet</td>
<td style=" border: 1px solid black !important;">Gray</td>
</tr>
</table>
I tried to put display:inline-block; on the tables but I've got a FatalThrowableError.
Call to a member function get_cellmap() on null
I tried to change display:inline-block to float:left but I've got something like this
They were "side by side" but just the content moved to right. Borders are wrong.
How can I put 2 tables side by side using DomPDF?.
Setting position:absolute on 2nd table and adjusting per right/left/top/bottom css did the trick for me
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>";
Working on invoice module which has two different tables master_table and detail_table. Know i want to display master_table's data above the table then in the table structure showing data of detail_table for each three rows header.
My code looks this.
$n = 0;
$htmlpage = 1;
$query = $dbConnection->prepare("SELECT * FROM master WHERE (DocNo BETWEEN ? AND ?) ORDER BY DocNo ASC");
$query->execute(array($fdcu,$tdcu));
while($rows = $query->fetch())
{
$n++;
$noInvs = $rows['No_of_Inv'];
$dno = $rows['DocNo'];
$name = $rows['Customer_Name'];
Step-1: Now i'm pulling client data from another table
$qry = $dbConnection->prepare("SELECT * FROM client WHERE client_name=?");
$qry->execute(array($name));
$row = $qry->fetch();
$add = $row['address'];
$city = $row['city'];
$proj = $rows['Project'];
$projNo = $rows['Project_No'];
$sermnth = $rows['Service_Month'];
$grandtotal = $rows['Total_Amt'];
$rupee = number2word($grandtotal);
$index = 1;
$ratetot = 0;
$subtotal = 0;
$lastPage = ceil($noInvs/3);
$pageCount = 0;
Step-2: Now check the loop iteration
while($index <= $noInvs)
{
$cnt = 1;
$body = "<div class='main-container'><table width='100%' style='padding:0 0 0 0;' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' align='center' style='border:1px solid #000;'>
<strong style='font-size:30px;'>Data</strong>
</td>
</tr>
<tr>
<td valign='top' align='left' style='padding: 0 0px 0 0px;border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;'>
<table width='100%' align='left' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' style='width:50%; padding:5px; font-size:13px; border-right: solid 1px #000000;text-align:left;'><strong>CUSTOMER:</strong> <br /><p style='font-size:12px;'>$name<br />$add, $city</p></td>
<td valign='top' style='width:50%; font-size:13px;'>
<table width='100%' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='border-right: solid 1px #000000;padding:5px;width:40%;font-size:12px;'><br />Invoice No:<br />Invoice Date:</td>
<td align='left' style='padding:5px;font-size:12px;'><br />$ino<br />$invdate</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;'>
<table width=100% cellpadding='0' cellspacing='0' >
<tbody>
<tr style='border-right:solid 1px #000000;border-bottom:solid 1px #000000;'>
<td style='width:5%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>SN.</td>
<td style='width:45%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Description of Services</td>
<td style='width:13%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Per</td>
<td style='width:10%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Quantity</td>
<td style='width:12%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Rate</td>
<td style='width:15%;text-align:center; border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Amount in Rs.</td>
</tr>";
Step-4: check the loop condition
while(true)
{
Step-5: checking the iteration count
if($cnt>3)
{
$pageCount++;
break;
}
Step-6: Pulling data from details table
$query1 = $dbConnection->prepare("SELECT * FROM details WHERE DocNo=? AND DocNO_Index=?");
$query1->execute(array($dno,$index));
$rowCnt = $query1->rowCount();
while($rows1 = $query1->fetch())
{
$desg = $rows1['Item'];
$des = $rows1['Description'];
$Quantity = $rows1['Quantity'];
$Rate = $rows1['Rate'];
$per = $rows1['Per'];
$gross = $rows1['Gross'];
$SERVICE_TAX = $rows1['SERVICE'];
$SERVICE_TAX = ($SERVICE_TAX==null)? 0.0 : $SERVICE_TAX;
$SB_Tax = $rows1['SB_Tax'];
$SB_Tax = ($SB_Tax==null)? 0.0 : $SB_Tax;
$Krishi_Kalyan_Cess = $rows1['Krishi_Kalyan_Cess'];
$Krishi_Kalyan_Cess = ($Krishi_Kalyan_Cess==null)? 0.0 : $Krishi_Kalyan_Cess;
$ratetot = $ratetot + $Rate;
$subtotal = $subtotal + $gross;
if($cnt == 1 && $index > 1)
{
$body.= "<tr><td style='width:5%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:45%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>Opening Balance</td><td style='width:13%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:10%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:12%;text-align:right;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($ratetot - $Rate, 2)." /-</td><td style='width:15%;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($subtotal-$gross, 2)." /-</td></tr>";
}
$body.= "<tr><td style='width:5%;height:90px;vertical-align:top;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>$index</td><td style='width:45%;height:90px;vertical-align:top; border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($proj!=null)
$body.= "$proj<br/>";
if($desg!=null)
$body.= "$desg<br/>";
if($des!=null)
$body.= "$des<br/>";
if($projNo!=null)
$body.= "$projNo<br/>";
if($sermnth!=null)
$body.= "$sermnth<br/>";
$body.= "</td><td style='width:13%;height:90px;vertical-align:top;text-align:center; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>$per</td><td style='width:10%;height:90px;vertical-align:top; border-right:solid 1px #000000;padding:3px 5px 3px 5px;text-align:center;;font-size:12px;'>$Quantity</td><td style='width:12%;height:90px;vertical-align:top;text-align:right; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($Rate,2)."/-</td><td style='width:15%;height:90px;vertical-align:top; padding:3px 5px 3px 5px; text-align:right;;font-size:12px;'>". number_format($gross,2)."/-</td></tr>";
if($cnt == 3 || $index == $noInvs)
{
$body.= "<tr><td style='width:5%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:45%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($index != $noInvs)
{
$body.= "Closing Balance";
}
$body.= "</td> <td style='width:13%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:10%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:12%;border-right:solid 1px #000;border-top:solid 1px #000;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($ratetot,2)."/-</td><td style='width:15%;border-top:solid 1px #000;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($subtotal,2)."/-</td></tr>";
}
}
$index++;
$cnt++;
}
$body .= "</tbody></table></td></tr>";
$stax = round($subtotal*($SERVICE_TAX/100),2);
$sbc = round($subtotal*($SB_Tax/100),2);
$kkc = round($subtotal*($Krishi_Kalyan_Cess/100),2);
$grandtotal = round(($subtotal+$stax+$sbc+$kkc),2);
$rupee = number2word($grandtotal);
$body .="<tr><td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;;font-size:12px;'><table cellpadding='0' cellspacing='0' width='100%'><tr><td rowspan='2' style='width:50%;height:50px; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount == $lastPage)
{
$body .= "<strong style='font-size:12px;'>Narration : </strong><br/>Amount in Words (Rupees):<br/>";
}
$body .= "<br/>$rupee";
$body .= "</td><td style='width:35%; border-bottom:solid 1px #000000;border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "Sub Total : <br />Service Tax # 14% <br />Swachh Bharat Cess # 0.5% <br />Krishi Kalyan Cess # 0.5% <br />";
}
$body .= "</td><td style='width:15%;text-align:right; border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "". number_format($subtotal,2)."/-<br />".number_format($stax,2)."/-<br />".number_format($sbc,2)."/-<br />".number_format($kkc,2)."/-<br />";
}
$body .= "</td></tr><tr><td style='width:35%; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "Total Amount";
}
$body .= "</td><td style='width:15%;text-align:right; padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount == $lastPage)
{
$body .= number_format($grandtotal,2)."/-";
}
$body .= "</td></tr></table></td></tr><tr><td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;;font-size:12px;'><table width='100%' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='width:50%; padding:3px 5px 3px 5px;border-right:1px solid #000;font-size:12px;'>
<strong>Thank you</strong>
</td>
<td valign='bottom' align='center' style='width:50%; text-align:center;font-size:12px;'>
<strong>AUTHORISED SIGNATORY</strong>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<p> </p></div>";
$body .= "<html><head><title>$ino</title><style type='text/css'>.main-container{display: block;} #media print{.main-container{display: block;}#page{size:portrait;margin:10px auto;padding:0}.main-container{page-break-after:always!important;}}</style><script language='javascript' type='text/javascript'>function PrintPage() { window.print(); } </script></head><body style='font-size: 12px ! important;'>$body</body></html><!-- onload='window.print()'-->";
echo "$body";
}
}
Issue is loop iteration.
My code output like this
Any suggestions on how to do this or to point me in the right direction would be greatly appreciated.
You're trying to re-use an active database connection. That doesn't work. You need two connections.
Specifically, you're in the process of reading a result set from a query on your connection,
$query = $dbConnection->prepare("some query");
$query->execute(array($fdcu,$tdcu));
while($rows = $query->fetch()) {
...
when you issue another query on the same $dbConnection ...
$qry = $dbConnection->prepare("another query");
$qry->execute(array($name));
You Can't Do That™ while the first query is still active. Open up and use a different connection for the queries issued from inside your loop.
I want to run a foreach loop inside a msgHTML on PHP Mailer to make the table td dynamic from array. Below is the latest code I have. I' am working on dreamweaver and it show that this code has errors, I don't know how to solve this issue.
<?php
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$mail->MsgHTML(
"
Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
"
?>
<?php
foreach($variable as $var){
?>
<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
<?php
}
?>
<?php "
</table>
");
?>
How about this code?
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$msg = "Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
foreach($variable as $var){
$msg .= "<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
} // foreach
$msg .= "</table>";
$mail->MsgHTML( $msg );
try this
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$message =
"
Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
";
foreach ($variable as $var) {
$message .= "<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
}
$message .= "
</table>
";
$mail->MsgHTML($message);
I'm reading a table data from MYSQL and writing it in html format to generate PDF (using TCPDF LIbrary) . but in resulting PDF only some of inline html CSS are affecting including(color,width.height) but other css like border-botttom(which I need the most) or all others ar being ignored by library.
$bookings_table_Result = mysql_query($bookings_table_query);
$tbl_header = '<table style=\"width:900px; border: 1px solid black; padding:0px;\">';
$tbl_footer = '</table>';
$tbl = '';
while($row = mysql_fetch_array($bookings_table_Result)){
$checkin = $row["checkin"];
$checkout = $row["checkout"];
$nights = $row["nights"];
$guest = $row["guest"];
$country = $row["country"];
$guestcount = $row["guestcount"];
$amount = $row["amount"];
$tbl .= '<tr >
<td style="border-bottom: solid 1px Black; width: 80px;">'.$checkin.'</td>
<td style="border: 1px solid #000000; width: 80px;">'.$checkout.'</td>
<td style="border: 1px solid #000000; width: 20px;">'.$nights.'</td>
<td style="border: 1px solid #000000; width: 200px;">'.$guest.'</td>
<td style="border: 1px solid #000000; width: 150px;">'.$country.'</td>
<td style="border: 1px solid #000000; width: 40px;">'.$guestcount.'</td>
<td style="border: 1px solid red; width: 80px; color: blue;">'.$amount.'</td>
</tr>';
};
$tbl .= '</table>';
$pdf->writeHTML($tbl, true, false, true, false, '');
I Uploaded the picture of Result PDF
You have a typo error in the line you use border-bottom , see:
... '<table style="width: 900px; border-bottom:1pt solid black;" border: 1px; cellspacing="0">';
This is out of the style attribute!! ------^
From the look of it, you are not generating a valid html table: You don't seem to add the table header to your $tbl variable.
If that is not the problem (you don't show where you output the table...), you'd better post the generated html instead of the php as this seems more related to html and css than php.
when you echo a style in html using php try changing your code to something like this:
$tbl .= '<tr >
<td style=\"border: 1px solid #000000; width: 80px;\">'.$checkin.'</td>
<td style=\"border: 1px solid #000000; width: 80px;\">'.$checkout.'</td>
<td style=\"border: 1px solid #000000; width: 20px;\">'.$nights.'</td>
<td style=\"border: 1px solid #000000; width: 200px;\">'.$guest.'</td>
<td style=\"border: 1px solid #000000; width: 150px;\">'.$country.'</td>
<td style=\"border: 1px solid #000000; width: 40px;\">'.$guestcount.'</td>
<td style=\"border: 1px solid #000000; width: 80px;\">'.$amount.'</td>
</tr>';
when using single quote '' you need need to include backslashes to tell the server to keep the "" when echoing your table.
I had a similar problem when i was using php to echo my tables from mysql db.
jeroen makes a good point. You need to add the beginning table declaration if you want to create a valid html table.
You also seem to be styling the table outside of your style definition as well.
change
$tbl_header = '<table style="width: 900px; border-bottom:1pt solid black;" border: 1px; cellspacing="0">';
to
$tbl_header = '<table style=\"width:900px; border-bottom:1px solid black; border: 1px solid black; padding:0px;\">
However probably no point in the border on the bottom then one on the entire table because your last border declaration is going to override the previous one. . .