rwd-table Font not visible in Mobile devices - php

.rwd-table {
margin: 1em 0;
min-width: 300px;
}
.rwd-table tr, th, td{
border: 2px solid #000000;
}
.rwd-table tr {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.rwd-table th {
display: none;
}
.rwd-table td {
display: block;
}
.rwd-table td:first-child {
padding-top: .5em;
}
.rwd-table td:last-child {
padding-bottom: .5em;
}
.rwd-table td:before {
content: attr(data-th) " ";
font-weight: bold;
width: 13.5em;
display: inline;
}
#media (min-width: 480px) {
.rwd-table td:before {
display: none;
}
}
.rwd-table th, .rwd-table td {
text-align: left;
}
#media (min-width: 480px) {
.rwd-table th, .rwd-table td {
display: table-cell;
padding: .25em .5em;
}
.rwd-table th:first-child, .rwd-table td:first-child {
padding-left: 0;
}
.rwd-table th:last-child, .rwd-table td:last-child {
padding-right: 0;
}
}
body {
text-rendering: optimizeLegibility;
color: #000000;
background: #eee;
}
h1 {
font-weight: normal;
letter-spacing: -1px;
color: #000000 !important;
}
.rwd-table {
background: #fff;
color: #000000;
border-radius: .4em;
}
.rwd-table tr {
border-color: #fff;
}
.rwd-table th, .rwd-table td {
margin: .5em 1em;
}
#media (min-width: 480px) {
.rwd-table th, .rwd-table td {
padding: 1em !important;
-webkit-text-fill-color: rgba(0, 0, 0, 1);
-webkit-opacity: 1;
color: rgba(0, 0, 0, 1);
background: white;
}
}
.rwd-table th, .rwd-table td:before {
color: black;
}
<table class="rwd-table">
<tr>
<td colspan="2" style="text-align: center; color: black;"><?php the_field( 'header_note_payment' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Account Name </td>
<td bgcolor="" style="color: black;"><?php the_field( 'account_name' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Bank Name </td>
<td bgcolor="" style="color: black;"><?php the_field( 'bank_name' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Branch Code</td>
<td bgcolor="" style="color: black;"><?php the_field( 'branch_code' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Account No</td>
<td bgcolor="" style="color: black;"><?php the_field( 'account_number' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">IBAN</td>
<td bgcolor="" style="color: black;"><?php the_field( 'iban' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Currency</td>
<td bgcolor="" style="color: black;"><?php the_field( 'currency' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">SWIFT Code</td>
<td bgcolor="" style="color: black;"><?php the_field( 'swift_code' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Bank Address</td>
<td bgcolor="" style="color: black;"><?php the_field( 'bank_address' ); ?></td>
</tr>
<tr style="text-align: center; color: black;">
<td colspan="2"><?php the_field( 'footer_note_payment' ); ?></td>
</tr>
</table>
<table class="rwd-table">
<tr>
<td colspan="2" style="text-align: center; color: black;"><?php the_field( 'header_note_payment' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Account Name </td>
<td bgcolor="" style="color: black;"><?php the_field( 'account_name' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Bank Name </td>
<td bgcolor="" style="color: black;"><?php the_field( 'bank_name' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Branch Code</td>
<td bgcolor="" style="color: black;"><?php the_field( 'branch_code' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Account No</td>
<td bgcolor="" style=" color: rgba(0, 0, 0, 1) !important;">011 650 777 003</td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">IBAN</td>
<td bgcolor="" style="color: black;"><?php the_field( 'iban' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Currency</td>
<td bgcolor="" style="color: black;"><?php the_field( 'currency' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">SWIFT Code</td>
<td bgcolor="" style="color: black;"><?php the_field( 'swift_code' ); ?></td>
</tr>
<tr>
<td bgcolor="#A8CCC9" style="color: black;">Bank Address</td>
<td bgcolor="" style="color: black;"><?php the_field( 'bank_address' ); ?></td>
</tr>
<tr style="text-align: center; color: black;">
<td colspan="2"><?php the_field( 'footer_note_payment' ); ?></td>
</tr>
</table>
I have added css code & html code as well, please do let me know where exactly i am going wrong. fighting with this particular line from past two days.
Tried using different css style but, everything works on the desktop screens, but in the mobile screen, only Heading gets displayed i.e. ACCOUNT NUMBER.

Shouldn't it be <?=the_field('account_number')?> BTW, 'account no' isn't the heading - its just the previous cell, a sibling.

Related

How do I vertically align text & image in a table cell

So my problem can be seen in this picture:
How do I make every cell have the text at the same height? The last <th> (text+img) drags it down for some reason.
My css:
.table {
width: 100%;
padding: 0;
margin: 15px 0 0;
border-collapse: collapse
}
.table th {
text-align: left;
color: #fff;
background: 0 0;
text-transform: uppercase;
font-size: .9em;
line-height: 1em;
padding: .5em;
}
.table th.gold {
color: #ffdd45
}
.table td {
padding: .7em .5em .6em;
font-size: 1.1em;
line-height: 1.2em;
background: #222;
border: 2px solid rgba(0, 0, 0, 0);
vertical-align: middle;
}
<table class="table rate" style="margin-top: 0;">
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Number 1</th>
<th class="gold">Number 2</th>
<th>text+img</th>
</tr>
</thead>
<tbody id="players-table1">
<tr>
<td style="text-align: center;">1</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user0</span></a>
</td>
<td>4</td>
<td class="bold gold">500</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user</span></a>
</td>
<td>4</td>
<td class="bold gold">400</td>
<td style="width:10%"><i>35x<img src="piclink" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="piclink" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="piclink"/></i></td>
</tr>
</tbody>
</table>
There are 2 ways to fix this:
Decreasing the height of the image(which is what I did in answer), this was 10% before and I made it as 5%. The td content was pushing down due to that.
If you don't want to decrease the height of the image then you have to increase the height of the each row so that the height can easily fit-in.
so call is yours what to choose.
.table {
width: 100%;
padding: 0;
margin: 15px 0 0;
border-collapse: collapse
}
.table th {
text-align: left;
color: #fff;
background: 0 0;
text-transform: uppercase;
font-size: .9em;
line-height: 1em;
padding: .5em;
}
.table th.gold {
color: #ffdd45
}
.table td {
padding: .7em .5em .6em;
font-size: 1.1em;
line-height: 1.2em;
background: #222;
border: 2px solid rgba(0, 0, 0, 0);
vertical-align: middle;
border: 1px solid red;
}
<table class="table rate" style="margin-top: 0;">
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Number 1</th>
<th class="gold">Number 2</th>
<th>text+img</th>
</tr>
</thead>
<tbody id="players-table1">
<tr>
<td style="text-align: center;">1</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user0</span></a>
</td>
<td>4</td>
<td class="bold gold">500</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user</span></a>
</td>
<td>4</td>
<td class="bold gold">400</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
</tbody>
</table>

PHP Mpdf - move table to next page if it doesn't fit in actually page

I have to create dynamically a PDF file using Mpdf. The page/s contain multiple tables.
I would like to move the table to the next page if it doesn't fit in the page. At the moment it brokes in 2 pieces (once piece in one page, check the image I added).
Is there any possibility to move the table to the next page? Like I said, I create the file dynamically, so I don't know how many tables I have or how long will be the last row (with text) of the table.
[![At the end, it breaks in 2 pieces][1]][1]
Here is a table example:
body {
font-family: Arial;
line-height:12px;
color: #000000;
font-size:10px;
}
p{
margin: 0 0 10px;
}
h1 {
text-transform: uppercase;
font-size: 16px;
font-weight: bold;
margin-bottom:15px;
}
.nabidka-container {
width:1000px;
margin: 0 auto;
}
.nabidka-container .products:first-child {
margin-bottom:40px;
}
.nabidka-container .products{
border-collapse: collapse;
margin: 35px 0 40px 0;
table-layout: fixed;
width: 100%;
overflow:wrap;
display:block;
page-break-inside:auto
}
.nabidka-container .products,.nabidka-container .products tr td, .nabidka-container .products tr th {
page-break-inside: initial !important;
}
.nabidka-container .products td {
width:25%;
border: 1px solid gray;
padding:2px;
text-align: center;
}
.nabidka-container .products td.foto {
border: 0px;
}
.nabidka-container .products td.bezramu {
border: 0px;
background-color: #ffffff;
}
.nabidka-container .products .tab_popis {
width: 200px;
}
.nabidka-container .products .tab_hodnoty {
width: 50px;
}
.nabidka-container .products .bold {
font-weight: bold;
}
.nabidka-container .products .italic {
font-style: italic;
}
.nabidka-container .products .left {
text-align: left;
}
.nabidka-container .products .right {
text-align: right;
}
.nabidka-container .products .price {
background-color: #cecece;
font-weight: bold;
}
<div class="nabidka-container">
<table class="products" style="width:100%">
<tbody>
<tr>
<td class="tab_popis foto"> </td>
<td class="tab_hodnoty foto"><img src="https://devlocal.optimtop.cz/storage/files/sources/images/products/p283_01_small.jpg" class="foto"></td>
<td class="tab_hodnoty foto"><img src="https://devlocal.optimtop.cz/storage/files/sources/images/products/p213_01_small.jpg" class="foto"></td>
<td class="tab_hodnoty foto"><img src="https://devlocal.optimtop.cz/storage/files/sources/images/products/p275_01_small.jpg" class="foto"></td>
<td class="tab_hodnoty foto"><img src="https://devlocal.optimtop.cz/storage/files/sources/images/products/p188_01_small.jpg" class="foto"></td>
</tr>
<tr>
<td class="tab_popis foto"> </td>
<td class="tab_hodnoty bold">Válcové brikety</td>
<td class="tab_hodnoty bold">Brikety RUF</td>
<td class="tab_hodnoty bold">Brikety RUF</td>
<td class="tab_hodnoty bold">Noční brikety</td>
</tr>
<tr>
<td class="tab_popis left">Kód</td>
<td class="tab_hodnoty">DBVMPR800</td>
<td class="tab_hodnoty">RUFHEX840</td>
<td class="tab_hodnoty">RUFMEX840</td>
<td class="tab_hodnoty">NOCVB720</td>
</tr>
<tr>
<td class="tab_popis left">Hmotnost balení</td>
<td class="tab_hodnoty">10 kg</td>
<td class="tab_hodnoty">10 kg</td>
<td class="tab_hodnoty">10 kg</td>
<td class="tab_hodnoty">10 kg</td>
</tr>
<tr>
<td class="tab_popis left">Hmotnost palety</td>
<td class="tab_hodnoty">800 kg</td>
<td class="tab_hodnoty">840 kg</td>
<td class="tab_hodnoty">840 kg</td>
<td class="tab_hodnoty">720 kg</td>
</tr>
<tr>
<td class="tab_popis left">Počet balení na pal.</td>
<td class="tab_hodnoty">80</td>
<td class="tab_hodnoty">84</td>
<td class="tab_hodnoty">84</td>
<td class="tab_hodnoty">72</td>
</tr>
<tr>
<td class="tab_popis left">Průměrná výhřevnost</td>
<td class="tab_hodnoty">18.8 MJ/kg</td>
<td class="tab_hodnoty">18.5 MJ/kg</td>
<td class="tab_hodnoty">18 MJ/kg</td>
<td class="tab_hodnoty">18 MJ/kg</td>
</tr>
<tr>
<td class="tab_popis left price">Cena/ks</td>
<td class="tab_hodnoty price">41.88 Kč</td>
<td class="tab_hodnoty price">46.43 Kč</td>
<td class="tab_hodnoty price">40.48 Kč</td>
<td class="tab_hodnoty price">53.47 Kč</td>
</tr>
<tr>
<td class="tab_popis left price">Cena/paleta</td>
<td class="tab_hodnoty price">3350 Kč</td>
<td class="tab_hodnoty price">3900 Kč</td>
<td class="tab_hodnoty price">3400 Kč</td>
<td class="tab_hodnoty price">3850 Kč</td>
</tr>
<tr>
<td class="tab_popis left price">Cena/tuna</td>
<td class="tab_hodnoty price">4188 Kč</td>
<td class="tab_hodnoty price">4643 Kč </td>
<td class="tab_hodnoty price">4048 Kč</td>
<td class="tab_hodnoty price">5347 Kč</td>
</tr>
<tr>
<td class="tab_popis bezramu"></td>
<td class="tab_hodnoty italic ">SUPER CENA průměr 9 mm</td>
<td class="tab_hodnoty italic ">100% buk</td>
<td class="tab_hodnoty italic ">SUPER CENA dub,buk,jasan</td>
<td class="tab_hodnoty italic ">dlouhá doba žhnutí</td>
</tr>
</tbody>
</table>
</div>
Thanks for your help.
I manage to fix it using page-break-inside: avoid. But you need to add $mpdf->shrink_tables_to_fit = 1; to your mpdf object or attribute autosize="1" to your table element. (without shirt_tables_to_fit or autosize, it will add one table to one page (at least that was the behaviour in my case).
For more info about table shrink check Tables - Tables - mPDF Manual

PDF gets breack when printing dompdf

hi I am using dompdf for generating pdf from HTML but not able to understand why it gets break while printing the pdf
here is my function
public function printRunsheetBymanifestAction()
{
$manifestId = $this->params()->fromRoute('id', 0);
$getDetails = $this->getDeliveryTable()->getRunSheetData(array('manifestId' => base64_decode($manifestId)));
$getItemDetails = $this->getManifestTable()->getManifestItemsById($getDetails[0]['manifestId']);
$options = new Options();
$options->set('isRemoteEnabled', true);
$options->set('defaultFont','Courier');
$options->set('defaultPaperSize','A4');
$domPdf = new \Dompdf\Dompdf($options);
$domPdf->set_option('isHtml5ParserEnabled', true);
$view = $this->getServiceLocator()->get('ViewRenderer');
$viewModel = new ViewModel();
$viewModel->setTemplate('delivery/index/print-runsheet-bymanifest.phtml');
$viewModel->setVariable('results', $getDetails);
$viewModel->setVariable('itemDetails', $getItemDetails);
$content = $view->render($viewModel); //make html content for loadn in doampdf
$domPdf->loadHtml($content);
$domPdf->render();
$fileName = $getDetails[0]['runsheetNumber'].'_'.date('d_m_Y');
$domPdf->stream($fileName,array("Attachment"=>1));
exit;
}
here is my phtml template even I try the page break CSS for break the page after desired output
<?php $results = $this->results;
$items = $this->itemDetails;
?>
<style>
table.body {
width: 100%;
margin: 0 auto;
}
td.text-right{text-align: right;}
td.text-center{text-align: center;}
.page_breack{
clear: both;
page-break-after: always;
}
</style>
<table class="body" align="center" style="border-top: 1px solid #333; border-left: 1px solid #333; border-right: 1px solid #333;">
<tr>
<td>
<div id="header">
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td style="width: 30%">
<img style="width: 250px" src="<?=$this->basePath();?>/manifests/generate-barcode/<?php echo $results[0]['runsheetNumber']; ?>">
</td>
<td style="width: 70%">
<table class="row" style="width: 100%">
<tr>
<td >Location: <?php echo $results[0]['branchName']; ?></td>
</tr>
<tr>
<td >Website: www.xfas.in</td>
</tr>
<tr>
<td >
Daily Runsheet for : <?php echo $results[0]['allocated'.$results[0]['allocatedTo'].'Code'].' - '.$results[0]['allocated'.$results[0]['allocatedTo'].'Name']; ?>
</td>
</tr>
<tr>
<td class="text-right">
<strong>Printed # : <?php echo date('d.m.Y'); ?></strong>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table width="100%" style="border-collapse: collapse;">
<tr>
<th style="border-bottom: 2px dashed #333; border-top:2px dashed #333; text-align: center; height: 15px; ">SNo.</th>
<th style="border-bottom: 2px dashed #333; border-top:2px dashed #333; text-align: center; height: 15px; ">AwbNo.</th>
<th style="border-bottom: 2px dashed #333; border-top:2px dashed #333; text-align: center; height: 15px; ">Consignee Details</th>
<th style="border-bottom: 2px dashed #333; border-top:2px dashed #333; text-align: center; height: 15px; ">Pin Code</th>
<th style="border-bottom: 2px dashed #333; border-top:2px dashed #333; text-align: center; height: 15px; ">Signature</th>
</tr>
<?php if(count($items) > 0):
foreach ($items as $key => $val):
// $key = $key +1;
?>
<tr class="<?php
++$key;
if($key%14 == 0 && $key !=0)
echo "page_breack";
//echo ++$key; ?>" ><td style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"><?php echo $key; ?></td>
<td style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"><?php echo $val['Awb']; ?></td>
<td style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"><strong><?php echo $val['Consignee']; ?></strong><br>
<?php echo $val['Address'].', '.$val['Place'].', '.$val['ConsigneeArea']; ?>
</td>
<td style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"><?php echo $val['PinCode']; ?></td>
<td style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"></td>
</tr>
<?php endforeach; ?>
<?php
$ramainRow = count($items)%14;
if($ramainRow >0){
// $cnt = 14 - count($items);
for ($i =0; $i < $ramainRow; $i++){?>
<tr>
<td colspan="5" style="font-size: 12px; text-align:center; height: 65px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;"></td>
</tr>
<?php } ?>
<tr>
<td colspan="5" style="font-size: 12px; text-align:center; height: 53px; border-bottom: 1px solid #333; border-top:1px solid #333; border-collapse: collapse;">
<strong>Receiver Name:</strong> <?php echo $results[0]['allocated'.$results[0]['allocatedTo'].'Code'].' - '.$results[0]['allocated'.$results[0]['allocatedTo'].'Name']; ?><br>
<strong>Signature:</strong>
</td>
</tr>
<?php }?>
<?php endif;?>
</table>
</td>
</tr>
above is the htm fiel file for better understanding i am givig the pdf fil

How use where condition in left join in Laravel?

I want to retrieve all media in left side and if media contain data will fill those data.
Here is my view:
<tbody>
<?php $i= 0; ?>
#foreach($print as $get)
#if(count($get->media_id)>0 && $get->Status === "Approved")
<tr>
<?php $i++; ?>
<td style="font-size: 16px; width: 25px; "><?php echo $i; ?></td>
<td style="font-size: 16px; width: 30px">{{$get->media_name}}</td>
<td style="font-size: 16px; width: 98px">{{$get->Date_Occured}}</td>
<td style="font-size: 16px; width: 80px">{{$get->Page_Number}}</td>
<td style="font-size: 16px; width: 150px">{{$get->Content_title}}</td>
<td style="font-size: 16px; width: 470px">{!! nl2br(e($get->Content_Description)) !!}</td>
</tr>
#endif
#endforeach
#foreach($media as $medias )
<?php $i++; ?>
<tr>
<td style="font-size: 16px; width: 25px; "><?php echo $i; ?></td>
<td style="font-size: 16px; width: 30px">{{$medias['media_name']}}</td>
<td style="font-size: 16px; width: 98px"></td>
<td style="font-size: 16px; width: 80px"></td>
<td style="font-size: 16px; width: 150px"></td>
<td style="font-size: 16px; width: 470px">Hakuna Taarifa kwa Leo</td>
</tr>
#endforeach
</tbody>
Here is my controller:
public function printpreview() {
$print = DB::table('media')
->leftjoin('content_forms', 'media.id', "=", 'content_forms.media_id')
->select('media.*','content_forms.*')
->whereDate('content_forms.created_at', DB::raw('CURDATE()'))
->get();
$media = media::all()->toArray();
return view('pdf.printview', compact('print', 'media'));
}

PHP-MYSQL: Not able to fetch multiple record from database into word file

I have to download the records from database into a word file. But m not able to do so as whenever i add while loop around the table it is giving me error.
My code is working fine when i fetch single records.
Can anbody provide me the way to fetch multiple records.
Here is my Code:
<?php
include('dbcon.php');
if($_GET['id']!='')
$id=$_GET['id'];
$party_name=mysql_query("select * FROM tb_party Where party_id='".$id."' ");
$party_name_row=mysql_fetch_array($party_name);
$sample_text1 = $party_name_row['party_name'];
$party_details="select * from tb_party_rate_entry
where party_id='$id'";
$query_details=mysql_query($party_details);
$row_details=mysql_fetch_array($query_details);
$word_xmlns = "xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word'
xmlns='http://www.w3.org/TR/REC-html40′";
$word_xml_settings = "<xml><w:WordDocument>
<w:View>Print</w:View><w:Zoom>100</w:Zoom></w:WordDocument></xml>";
$word_landscape_style =
"#page {size:8.5in 11.0in; margin:0.5in 0.31in 0.42in 0.25in;
} div.Section1{page:Section1;}";
$word_landscape_headinh="{font-size:15px; }";
$word_landscape_div_imf='
<img src="http://silverevents.net/user_image/' .$sample_text1 . '"
height="150" width="150"/>';
$word_landscape_div_start = "<div class='Section1′>";
$word_landscape_div_end = "</div>";
$content = '<html '.$word_xmlns.'>
<head>
<title>Party Rate Report</title>'
.$word_xml_settings.'<style type="text/css">
'.$word_landscape_style.' table,td
{border:1px solid #FFFFFF; width:200px; color:#CCC;} </style>
</head>
<body>'.$word_landscape_div_start .
'<table style="width:500px; color:#000000;
margin:0 0 50px 100px; font-family: Arial Black, Gadget,
sans-serif; font-size:24px;"><tr><td> Party Rate Report </td>
</tr></table></br>
<table style="width:700px;font-size:15px;font-family:
Arial Black, Gadget, sans-serif;">
<tr>
<td width="180">
Party Name : '. $party_name_row['party_name'] . '
</td>
<td width="250">
Address : '. $party_name_row['party_address'] . '
</td>
<td width="150">
Phone : '. $party_name_row['phone_no']. '
</td>
</tr>
</table><br/>
<table style="width:700px; color:#00000; margin:22px 0 0 0px;
font- family:Helvetica, sans-serif, Verdana;
font-size:15px; border1px solid #666;">
<tr>
<td style=" border:1px solid #666; width:300px;"> Zone</td>
<td style=" border:1px solid #666; width:300px;">
Delivery Mode
</td>
<td style=" border:1px solid #666; width:300px;"> Doc Type </td>
<td style=" border:1px solid #666; width:300px;"> Weight slot </td>
<td style=" border:1px solid #666; width:300px;"> Weight Unit </td>
<td style=" border:1px solid #666; width:300px;"> Flat </td>
<td style=" border:1px solid #666; width:300px;"> Price </td>
</tr>
<tr>
<td style=" border:1px solid #666; width:300px;">' .
$row_details['zone_id']. '</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['delivery_mode_id'].'
</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['doc_type_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['weight_slot_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['weight_measure_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['flat'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['price' ] . '</td>
</tr>
</table></br>' . $word_xml_settings. $word_landscape_div_end.'
</body>
</html>';
#header('Content-Type: application/msword');
#header('Content-Length: '.strlen($content));
#header('Content-disposition: inline; filename="Party Rate Report.doc"');
echo $content;
?>
Here my database:
Quick reformat, adding a loop (and assuming the id is an integer):-
<?php
include('dbcon.php');
if($_GET['id']!='')
{
$id=intval($_GET['id']);
$party_name=mysql_query("select * FROM tb_party Where party_id=$id ");
if ($party_name_row=mysql_fetch_array($party_name))
{
$sample_text1 = $party_name_row['party_name'];
}
$word_xmlns = "xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word'
xmlns='http://www.w3.org/TR/REC-html40'";
$word_xml_settings = "<xml><w:WordDocument>
<w:View>Print</w:View><w:Zoom>100</w:Zoom></w:WordDocument></xml>";
$word_landscape_style =
"#page {size:8.5in 11.0in; margin:0.5in 0.31in 0.42in 0.25in;
} div.Section1{page:Section1;}";
$word_landscape_headinh="{font-size:15px; }";
$word_landscape_div_imf='
<img src="http://silverevents.net/user_image/' .$sample_text1 . '"
height="150" width="150"/>';
$word_landscape_div_start = "<div class='Section1'> ";
$word_landscape_div_end = "</div>";
$content = '<html '.$word_xmlns.'>
<head>
<title>Party Rate Report</title>'
.$word_xml_settings.'<style type="text/css">
'.$word_landscape_style.' table,td
{border:1px solid #FFFFFF; width:200px; color:#CCC;} </style>
</head>
<body>'.$word_landscape_div_start .
'<table style="width:500px; color:#000000;
margin:0 0 50px 100px; font-family: Arial Black, Gadget,
sans-serif; font-size:24px;"><tr><td> Party Rate Report </td>
</tr></table></br>
<table style="width:700px;font-size:15px;font-family:
Arial Black, Gadget, sans-serif;">
<tr>
<td width="180">
Party Name : '. $party_name_row['party_name'] . '
</td>
<td width="250">
Address : '. $party_name_row['party_address'] . '
</td>
<td width="150">
Phone : '. $party_name_row['phone_no']. '
</td>
</tr>
</table><br/>
<table style="width:700px; color:#00000; margin:22px 0 0 0px;
font- family:Helvetica, sans-serif, Verdana;
font-size:15px; border1px solid #666;">
<tr>
<td style=" border:1px solid #666; width:300px;"> Zone</td>
<td style=" border:1px solid #666; width:300px;">
Delivery Mode
</td>
<td style=" border:1px solid #666; width:300px;"> Doc Type </td>
<td style=" border:1px solid #666; width:300px;"> Weight slot </td>
<td style=" border:1px solid #666; width:300px;"> Weight Unit </td>
<td style=" border:1px solid #666; width:300px;"> Flat </td>
<td style=" border:1px solid #666; width:300px;"> Price </td>
</tr>';
$party_details="select *
from tb_party_rate_entry
where party_id=$id";
$query_details=mysql_query($party_details);
while($row_details=mysql_fetch_array($query_details))
{
$content .= '<tr>
<td style=" border:1px solid #666; width:300px;">' .
$row_details['zone_id']. '</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['delivery_mode_id'].'
</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['doc_type_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['weight_slot_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['weight_measure_id'].'</td>
<td style=" border:1px solid #666; width:300px;">'.
(($row_details['flat'] != '') ? $row_details['flat'] : ' ').'</td>
<td style=" border:1px solid #666; width:300px;">'.
$row_details['price' ] . '</td>
</tr>';
}
$content .= '</table></br>' . $word_xml_settings. $word_landscape_div_end.'
</body>
</html>';
#header('Content-Type: application/msword');
#header('Content-Length: '.strlen($content));
#header('Content-disposition: inline; filename="Party Rate Report.doc"');
echo $content;
}
?>
Note for new code you probably should switch to using mysqli rather than the php mysql drivers
do something like this:
while ($row_details=mysql_fetch_array($query_details)) {
//do row specific code
}

Categories