I am trying to generate pdf using dom pdf
But in header part of pdf, image and text are overlapping.
Couldn't identify what exactly is wrong in my code?
CodeIgniter controller function:
$dompdf = new Dompdf();
$dompdf->set_option('enable_css_float', true);
$contxt = stream_context_create([
'ssl' => [
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
'allow_self_signed'=> TRUE
]
]);
$options = new Options();
$dompdf->setHttpContext($contxt);
$dompdf->set_option('isRemoteEnabled', true);
$dompdf->set_option('debugKeepTemp', true);
$dompdf->set_option('isHtml5ParserEnabled', true);
$dompdf->loadHtml($pdfdata);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$output = $dompdf->output();
Codeigniter View
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
<link rel="stylesheet" href="<?php echo CSS_PATH_BACKEND; ?>bootstrap.min.css">
<style>
#page { margin: 20px 30px; }
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:6px;}
.table-bordered{border:2px solid #000;}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{border:2px solid #000;}
.list-inline>li{ display: inline-block;
padding-right: 35px;
padding-left: 35px;
padding-top: 10px;
font-weight: 700;}
body{font-size:13px;}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:5px 0 5px 10px;}
.goods-table td{border:2px solid #000; }
thead:before, thead:after { display: none; }
tbody:before, tbody:after { display: none; }
tbody:before, tbody:after { display: none; }
.invoice tr td{}
.product_invoice td{padding:4px 5px !important;}
li{padding: 10px 0;}
li:before{content:''; font-size:60px; line-height:20px; vertical-align:middle;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr>
<td>
<div class="invoice-title">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;width:380px;height:76px;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
<p style="padding: 5px 0 0 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Corporate Office: Some address</p>
<p style="padding: 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Phone: 87945456 Cell: 321456789 Email: info#example.com Website: www.example.com</p>
</div>
<div class="invoice-title">
<span class="text-center" style="margin: 5px 0 0 0;font-weight:700;text-align: center;display: block;font-size: 18px;">TAX INVOICE CUM CHALLAN</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="">
<div class="">
<div class="table-responsive">
<!--<table class="table table-condensed">-->
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr style="border:2px solid #000;">
<td rowspan="4" style="width:40%;" colspan="2">
<!--StartFragment-->
<p style="padding: 0;margin: 0;font-size: 13px;"><span >To,</span></p>
<p style="padding: 0;margin: 0;font-weight: 700;font-size: 13px;"><span ><?php echo $customer['name']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address1']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['city']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span >Phone No: <?php echo $customer['contact_no']; ?></span></p>
</td>
<td style="vertical-align:middle;width:30%;border:2px solid #000;">Invoice No: <span style="font-weight: 700;"><?php echo $invoice['invoice_no']; ?></span></td>
<td style="vertical-align:middle;width:30%;border:1px solid #000;" colspan="3" >Contact Person: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_name']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="vertical-align:middle;">Date: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['created_date'])); ?></span></td>
<td style="vertical-align:middle;" colspan="3">Mobile No: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_no']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" rowspan="2">RIN No: <span style="font-weight: 700;">87455454</span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" colspan="3"> VAT No: <span style="font-weight: 700;"></span></td>
</tr>
<tr style="border:2px solid #000;">
<!--<td >Company Executive: <?php echo ucwords($user['fname'] . ' ' . $user['lname']); ?></td>-->
<td colspan="1">Date of Activation: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['activation_date'])); ?></span></td>
<td colspan="3">Next Renewal: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['renewal_date'])); ?></span></td>
</tr>
</tbody>
</table>
<table width="100%" class="table goods-table invoice" style="margin-bottom: 0; font-size: 12px; border-top: 1px solid #202020; ">
<tbody>
<tr>
<td style="font-weight: 700;font-size: 13px;width:10%;">Sr. No</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Software ID</td>
<td style="font-weight: 700;font-size: 13px;width:35%;">Description</td>
<td style="font-weight: 700;font-size: 13px;width:10%;">Quantity</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Unit Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
<td style="font-weight: 700;font-size: 13px;width:15%" colspan="2">Total Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
</tr>
<?php
$cnt = 1;
foreach ($product_invoice as $key => $value) {
?> <tr <?php
if (count($product_invoice) < 9) {
echo 'class';
} else {
echo 'class="product_invoice"';
}
?>>
<td
<?php if (count($product_invoice) == 1) { ?> style="height:650px;"<?php } ?>
<?php if (count($product_invoice) == 2 && ($key == (count($product_invoice)) - 1)) { ?> style="height:590px;"<?php } ?>
<?php if (count($product_invoice) == 3 && ($key == (count($product_invoice)) - 1)) { ?> style="height:180px;"<?php } ?>
<?php if (count($product_invoice) == 4 && ($key == (count($product_invoice)) - 1)) { ?> style="height:160px;"<?php } ?>
<?php if (count($product_invoice) == 5 && ($key == (count($product_invoice)) - 1)) { ?> style="height:110px;"<?php } ?>
<?php if (count($product_invoice) == 6 && ($key == (count($product_invoice)) - 1)) { ?> style="height:50px;"<?php } ?>
<?php if (count($product_invoice) == 7 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 8 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 9 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 10 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>>
<?php echo $cnt++; ?></td>
<td><?php echo $value['software_id']; ?></td>
<td><?php echo $value['description']; ?></td>
<td><?php echo $value['qty']; ?></td>
<td colspan="2"><?php echo $value['unit_price']; ?></td>
<td><?php echo $value['total_price']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<table width="100%" class="table goods-table" style="margin-bottom: 0; font-size: 13px; padding: 15px 5px; ">
<tbody>
<tr>
<td colspan="2" rowspan="6" style="font-weight: 700;width:70%; padding: 10px 15px;">
<span style="font-weight:700;">Comments: </span>
</td>
<td style="width:15%;height:10px;">Sub Total</td>
<td style="width:25%;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['sub_total']; ?></td>
</tr>
<tr>
<td style="height:10px;">Other</td>
<td style="height:10px;"colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['other']; ?></td>
</tr>
<tr>
<td style="height:10px;">VAT</td>
<td style="height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['vat']; ?></td>
</tr>
<tr >
<td style="font-weight: 700;height:10px;font-size: 14px;">Grand Total</td>
<td style="font-weight: 700;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['total_price']; ?></td>
</tr>
<tr>
<td style="height:10px;">Mode Of Payment</td>
<td style="height:10px;" colspan="2"><?php
if ($invoice['paymode_mode'] == 1) {
echo 'Cash';
}
if ($invoice['paymode_mode'] == 2) {
echo 'Cheque';
}
if ($invoice['paymode_mode'] == 3) {
echo 'Cash and Cheque';
}
?></td>
</tr>
<tr>
<td colspan="3" >In Words: <?php echo ucwords(convert_number_to_words($invoice['total_price'])); ?> Rupees Only</td>
</tr>
<tr>
<td colspan="2">Installation Done<br>
<br><br><br>
Receiver's Signature with Seal
</td>
<td style="text-align: center;" colspan="3"><span style="font-weight: 700;font-size: 14px;">For </span><span style="font-weight: 700;font-size: 14px;">oft</span>
<?php if ($seg == "preview") {
?>
<img src="<?php echo IMAGE_PATH_BACKEND; ?>test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://example.com/images/backend/test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php } ?>
Authorized Signatory
</td>
</tr>
</tbody>
</table>
<table width="100%" class="table " style="margin-bottom: 0; font-size: 13px; border-bottom: 2px solid #000; border-left: 2px solid #000; border-right: 2px solid #000;">
<tbody>
<tr>
<td style="border-right: 2px solid #000;font-weight: 700;width: 100px;">Branches</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">sddsa</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">ewew</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 132px;">ewewq</td>
</tr>
<tr>
<td colspan="5" style="border : 2px solid #000;text-align: center;"><span style="font-weight:700;font-size: 13px;">Note: Computer generated Invoice and requires no signature.</span><br></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
There's a bug in Dompdf (current release 0.8.0) where styling an image with auto margins will cause it to no longer take up any vertical space in the layout.
Luckily your layout is such that working around the issue is fairly simple. Change the code around your image to the following:
<div class="text-center">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
</div>
Also of note: don't modify the display styling of images. Currently dompdf requires a special styling to render these correctly and if you change the styling (e.g. to display: block;) you may get unexpected results.
Related
Continue from the question Yii2 mPdf Kartik: Set Height and Width Paper
I have problem width position absolute on page footer.
I have set it up position: absolute; and bottom: 0;
But page footer not in actual position.
The position should be like this:
this is my html code:
<?php
$pages = 1;
$pageof = 1;
$totalPageof = ceil(count($model->details) /10);
$index = 0;
?>
<?php if(count($details) > 0) : ?>
<div class="page-wrapper">
<?php foreach($details as $detail) :
$index += 1;
?>
<?php if($pages == 1) : ?>
<div class="page-layout">
<!-- HEADER -->
<div class="page-header">
<table class="table-header">
<tbody>
<tr>
<td class="font12" width="250"><strong>COMPANY NAME</strong></td>
<td class="font14" width="250"><strong>PROFORMA INVOICE</strong></td>
<td>
<table>
<tr>
<td class="font11" width="80">NO. PO</td>
<td class="font11" width="10">:</td>
<td class="font11"><?=$model->no_po?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="font11" width="250">
<p>COMPANY ADDRESS</p>
</td>
<td class="font14" width="250"><?=$model->no_rorder?></td>
<td>
<table>
<tr>
<td class="font10" width="80"><?=(!empty($model->tgl_po)) ? date('d-M-Y', strtotime($model->tgl_po)) : NULL ?></td>
<td class="font10"><?=(!empty($model->tgl_tempo)) ? 'DUE DATE '. date(' d-M-Y', strtotime($model->tgl_tempo)) : 'DUE DATE -' ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding: 0;">
<table>
<tr>
<td class="font12" colspan="3">COMPANY PHONE</td>
</tr>
<tr>
<td class="font10" width="60">NPWP</td>
<td class="font10" width="10"></td>
<td class="font10"><?=isset($model->distributor) ? $model->distributor->npwp : '-' ?></td>
</tr>
<tr>
<td class="font10" width="60">SALESMAN</td>
<td class="font10" width="10">:</td>
<td class="font11"><?=isset($model->sales) ? (isset($model->sales->code)) ? $model->sales->code.'-'.$model->sales->name : $model->sales->name : '-' ?></td>
</tr>
<tr>
<td class="font10" width="60">NOTICE</td>
<td class="font10" width="10">:</td>
<td class="font10"><?=isset($model->salesType) ? $model->salesType->name : '-' ?></td>
</tr>
</table>
</td>
<td colspan="2">
<table>
<tbody>
<tr>
<td rowspan="2" class="font12 grid-1">Kepada YTH</td>
<td class="grid-2">
<p class="font12"><?=isset($model->outlet) ? $model->outlet_code.' - '.$model->outlet->name : '-' ?></p>
<p class="font12"><?=isset($model->outlet) ? $model->outlet->address : '-' ?></p>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td class="font10 text-left" style="padding-left:180px;" colspan="2">
<span>
Phone <?=isset($model->outlet) ? $model->outlet->phone_1 : '-' ?>
</span>
</td>
</tr>
<tr>
<td class="font10" width="200"><?=isset($model->outlet) ? $model->outlet->npwp : '-'?></td>
<td class="font10"><?='Page '. $pageof++ .' Of '. $totalPageof ?></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!-- /HEADER -->
<?php endif; ?>
<!-- /endif pages header -->
<!-- CONTENT -->
<?php if($pages == 1) : ?>
<div class="page-content">
<table class="table-content">
<thead>
<tr>
<th>KODE#</th>
<th>PRODUK</th>
<th colspan="5">QUANTITY</th>
<th>PRICE</th>
<th>DISC</th>
<th>SUB TOTAL</th>
</tr>
</thead>
<tbody>
<?php endif; ?>
<!-- /endif pages content -->
<tr>
<td class="text-right"><?=(isset($detail['typeproduct'])) ? '*'. $detail['product_code'] : $detail['product_code']?></td>
<td><?=$detail['product_name']?></td>
<td><?=($detail['comp_1'] && $detail['zqty_1'] != 0) ? number_format($detail['zqty_1']).'.'.$detail['comp_1'] : ''?></td>
<td><?=($detail['comp_2'] && $detail['zqty_2'] != 0) ? number_format($detail['zqty_2']).'.'.$detail['comp_2'] : ''?></td>
<td><?=($detail['comp_3'] && $detail['zqty_3'] != 0) ? number_format($detail['zqty_3']).'.'.$detail['comp_3'] : ''?></td>
<td><?=($detail['comp_4'] && $detail['zqty_4'] != 0) ? number_format($detail['zqty_4']).'.'.$detail['comp_4'] : ''?></td>
<td><?=($detail['comp_5'] && $detail['zqty_5'] != 0) ? number_format($detail['zqty_5']).'.'.$detail['comp_5'] : ''?></td>
<td class="text-right"><?=(!is_null($detail['zsprice_1'])) ? number_format($detail['zsprice_1'], 0, ',', '.') : ''?></td>
<td class="text-right"></td>
<td class="text-right"><?=(!is_null($detail['zjum_j'])) ? number_format($detail['zjum_j'], 0, ',', '.') : ''?></td>
</tr>
<!-- COUNTER ITEM -->
<?php if($pages == 10 || $index == count($details)) : ?>
</tbody>
</table>
</div>
<!-- /CONTENT -->
<!-- FOOTER -->
<?php if($totalPageof == ($pageof-1)) : ?>
<div class="page-footer">
<table class="table-footer">
<tbody>
<tr>
<td class="grid-1">
<p class="font9"><?=(!empty($model->keterangan)) ? '<i>##</i>'. $model->keterangan : NULL ?></p>
</td>
<td class="grid-2 text-right" width="200">
<p class="font12"><strong><?=(!$model->post) ? '' : '### PENCETAKAN ULANG ##' ?></strong></p>
<table>
<tbody>
<tr>
<td class="font9" width="60">Cetakan ke</td>
<td class="font9">:</td>
<td class="font9 text-right"><?= (!empty($model->post)) ? $model->print : 0 ?></td>
<td></td>
<td class="font9" width="60">Sub Total</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['total_j'], 0, ',', '.')?></td>
</tr>
<tr>
<td class="font9" width="60">Total Pcode</td>
<td class="font9">:</td>
<td class="font9 text-right"><?= count($details) ?></td>
<td></td>
<td class="font9" width="60">Disc Inv</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['disc_percent'], 0, ',', '.')?></td>
</tr>
<tr>
<td class="font9" width="60">Point</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['disc_point'], 0, ',', '.')?></td>
<td></td>
<td class="font9" width="60">DPP</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['dpp'], 0, ',', '.')?></td>
</tr>
<tr>
<td colspan="4"></td>
<td class="font9" width="60">PPN</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['ppn'], 0, ',', '.')?></td>
</tr>
<tr>
<td colspan="4"></td>
<td class="font10" width="60"><strong>TOTAL</strong></td>
<td class="font10">:</td>
<td class="font10 text-right"><strong><?=number_format($realJumlah['inv'], 0, ',', '.')?></strong></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="grid-1"></td>
<td class="grid-2 font10 money text-justify"><?=$realJumlah['terbilang']?></td>
</tr>
<tr>
<td class="grid-1">
<p class="font10">Admin SPV Gudang Pengirim Outlet</p>
<p class="font10">Produck yang sudah diterima harap diperiksa kembali</p>
<p class="color-white">----------------------------------------------------</p>
<p>----------------------------------------------------</p>
</td>
<td class="grid-2" style="padding-left: 80px;">
<table>
<tbody>
<tr>
<td class="font9">User</td>
<td class="font9">:</td>
<td class="font9"><?=Yii::$app->user->identity->profile->user->username?></td>
</tr>
<tr>
<td class="font9">Printed</td>
<td class="font9">:</td>
<td class="font9"><?= date('H:i:s', time()) ?></td>
</tr>
<tr>
<td class="font9">on</td>
<td class="font9">:</td>
<td class="font9"><?=date('d/m/Y')?></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<?php endif; ?>
<!-- /FOOTER -->
<?php endif; ?>
<!-- /COUNTER ITEM -->
</div>
<?php
$pages++;
if($pages > 10)
$pages = 1;
endforeach;
?>
<!-- /endforeach -->
</div>
<?php endif; ?>
<!-- /endif count -->
And this my css code:
/** page layout */
.page-wrapper {
height: 13.6cm;
width: 21.2cm;
}
.page-layout {
height: 13.6cm;
width: 21.2cm;
}
.page-footer {
bottom: 0;
position: absolute;
}
/** end page layout */
/** table style */
.table-header {
width: 100%;
}
.table-header tbody tr td {
padding-bottom: 0;
padding-top: 0;
vertical-align: text-bottom;
}
.table-header tbody tr td p {
margin: 0;
}
.table-header tbody tr td table {
width: 100%;
}
.table-header tbody tr td table tbody tr td.grid-1 {
width: 20%;
}
.table-header tbody tr td table tbody tr td.grid-2 {
width: 80%;
}
.table-content {
font-family: 'Couriere';
width: 100%;
}
.table-content thead tr th {
border-bottom: 1px dashed #000;
font-size: 12px;
font-weight: 300;
text-align: center;
}
.table-content tbody tr td {
font-size: 12px;
padding-bottom: 0;
padding-top: 0;
}
.table-footer {
width: 100%;
}
.table-footer tbody tr td {
padding-bottom: 0;
padding-top: 0;
position: relative;
}
.table-footer tbody tr td p {
margin: 0;
}
.table-footer tbody tr td.grid-1 {
vertical-align: text-bottom;
width: 70%;
}
.table-footer tbody tr td.grid-2 {
width: 30%;
}
.table-footer tbody tr td.money {
padding-left: 40px;
}
.table-footer tbody tr td table {
width: 100%;
}
/** end table style */
/** custom child */
.font9 {
font-size: 9px;
}
.font10 {
font-size: 10px;
}
.font11 {
font-size: 11px;
}
.font12 {
font-size: 12px;
}
.font14 {
font-size: 14px;
}
.text-right {
text-align: right;
}
.text-justify {
text-align: justify;
}
.color-white {
color: #fff;
}
/** end custom child */
May be someone has experienced it, hopefully it can be helped.
The code provided is while-loop, which work, part of the loop is to update database and to return the updated info back to loop that work too. The problem I am having is if the return result is more than one it should not loop that result only echo it once.
I have tried other ways of doing this, but nothing giving me the result I need, I have the amount of knowledge I have on PHP. If someone could please help me, there help would be greatly appreciated.
<?php
//////////////////////// non-spouse kid start ///////////////////////
$nonspouseKidSql=("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='son' AND familySide='other' OR memberEmail='$login_mem' AND familyRelationship='daughter' AND familySide='other' OR fam
ilyEmail='$login_mem' AND familyRelationship='father' AND familySide='other' OR familyEmail='$login_mem' AND familyRelationship='mother' AND familySide='other'");
$nonspouseKidQuery=mysql_query($nonspouseKidSql)or die ("error 1 Sorry we have a mysql error!");
$num_rowsNonspouseKid=mysql_num_rows($nonspouseKidQuery);
if ($num_rowsNonspouseKid < 1){echo '';}
else{
while($getnonspouseKidRow=mysql_fetch_array($nonspouseKidQuery)){
$getnonspouseKidEmail = $getnonspouseKidRow['familyEmail'];
$getNSPEmail = $getnonspouseKidRow['memberEmail'];
$nonspouseKid_relationship = $getnonspouseKidRow['familyRelationship'];
if($getNSPEmail == $login_mem){$nonspouseKidEmail = $getnonspouseKidEmail;}elseif($getnonspouseKidEmail == $login_mem){$nonspouseKidEmail = $getNSPEmail;}
$sql=("SELECT * FROM members WHERE email='$nonspouseKidEmail'");
$query=mysql_query($sql)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
while($row=mysql_fetch_array($query)){
$familyNonspouseKid_id = $row["id"];
$familyNonspouseKid_firstName = $row["firstName"];
$familyNonspouseKid_lastName = $row["lastName"];
$familyNonspouseKid_email= $row["email"];
$familyNonspouseKid_profile_pic = $row["profile_pic"];
$familyNonspouseKid_status = $row["status"];
$familyNonspouseKid_gender = $row["gender"];
if($nonspouseKid_relationship=="son"){$familyNonspouseKid_relationship ='son';}elseif($nonspouseKid_relationship=="daughter"){$familyNonspouseKid_relationship ='daughter';}
$member_familyPicNonspouseSon='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseSon='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a><div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseSon='<div id="connection_non-spouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
$member_familyPicNonspouseDaughter='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
if($familyNonspouseKid_relationship =='son'){echo $member_familyPicNonspouseSon;}else{echo $member_familyPicNonspouseDaughter;}
}
?>
<?php
//////// non-spouse kid end //////////////////////////////
?>
<?php
//////////////// child parent not spouse start ////////
?>
<div id="connection_childParent" class="connection_childParent"></div>
<div id="memFamilyPic_childParent" class="memFamilyPic_childParent">
<?php
$getGender = $mem["gender"];
if($getGender=='male'){$parentGender='Mother';}else{$parentGender='Father';}
$parentNameSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$nonspouseKidEmail' AND familyRelationship='mother' OR memberEmail='$nonspouseKidEmail' AND familyRelationship='father'")or die ("Sorry can't
get parent name!");
$parentNameRow=mysql_fetch_array($parentNameSql);
$parentName = $parentNameRow['familySide'];
$childParentSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='childmother' AND child_Id='$familyNonspouseKid_id' OR memberEmail='$login_mem' AND
familyRelationship='childfather' AND child_Id='$familyNonspouseKid_id'")or die ("Sorry can't get child parent!");
$childParentRow=mysql_fetch_array($childParentSql);
if($childParentRow < 1){echo '<p id="'.$familyNonspouseKid_id.'" class="mysql_returnNonspouseKid" align="center" style="color: #999; font-size:13px;">Child '.$parentGender.'</p>';
}else if($childParentRow > 2){
$childParentEmail = $childParentRow['familyEmail'];
$familyChildParent_relationship = $childParentRow["familyRelationship"];
$childParent=("SELECT * FROM members WHERE email='$childParentEmail'");
$query=mysql_query($childParent)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
if($childParentRow > 2){
while($row=mysql_fetch_array($query)){
$familyChildParent_id = $row["id"];
$familyChildParent_firstName = $row["firstName"];
$familyChildParent_lastName=$row["lastName"];
$familyChildParent_email=$row["email"];
$familyChildParent_profile_pic = $row["profile_pic"];
$familyChildParent_status=$row["status"];
$member_familyPicChildParent='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyChildParent_id.'/'.$familyChildParent_profile_pic.'';
if($familyChildParent_profile_pic!==""){
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyChildParent_id.'/'.
$familyChildParent_profile_pic.'" style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>';
}else{
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img
src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt=""/></a>';
}
}
if($familyChildParent_relationship =='childmother' or $familyChildParent_relationship =='childfather'){echo $member_familyPicChildParent;}
}}else{}
?>
<div id="familyDisplayDiv<?php echo $familyChildParent_id; ?>" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your <?php echo $familyChildParent_relationship; ?></span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;"><?php echo $familyChildParent_firstName; ?> <?php echo $familyChildParent_lastName; ?></span></td>
</tr>
</table>
</div>
</div>
<?php
}}
///////////////// child parent not spouse end //////////////
?>
I have a php script that generates report sheet of a class in a school. With other school classes selected the report sheet script works just fine but when you select this particular class it shows Internal Server Error
Peep the code be
<?php
session_start();
ob_flush();
include('server_func.inc');
//ini_set('max_execution_time', '600');
//ini_set('memory_limit', '-1');
ini_set('max_execution_time', '60000');
ini_set('memory_limit','12560M');
//set_time_limit('60000');
ini_set('mysql.connect_timeout','-1');
error_reporting(E_ALL);
ini_set('display_errors', '1');
$session = $_GET['session'];
$term = $_GET['term'];
//$classID = $_GET['classID'];
$config = system_config('TEST');
if(isset($_REQUEST['session']))
{
$session = $_REQUEST['session'];
}
else
{
echo 'No session selected';
exit;
}
if(isset($_REQUEST['term']))
{
$term = $_REQUEST['term'];
}
else
{
echo 'No term selected';
exit;
}
if(isset($_REQUEST['classID']))
{
$classID = $_REQUEST['classID'];
$class_list = class_list_view($session,$classID,'');
}
if(isset($_REQUEST['StudentID']))
{
$StudentID = $_REQUEST['StudentID'];
$classID = getStudentClass($session,$StudentID);
$class_list = class_list_view($session,$classID,$StudentID);
//if($_SESSION['school_id']==8)
//{
//echo "Check back later";
//break;
//}
}
else
{
$StudentID = '';
}
$cAverage = 0.0;
$totalScore = 0.0;
$fAverage = 0.0;
$hAverage = 0.0;
$lAverage = 0.0;
$current_session = current_session();
//$q1 = mysql_query("SELECT s1.StudentID, s2.StudentID FROM sch_student s1 INNER JOIN sch_student_list ON s1.StudentID = s2.StudentID WHERE ClassID = '$classID' AND Session ='$session'");
//$allstudents = mysql_num_rows($q1);
//$class_list = class_list_view($session,$classID,'');
//$class_list3 =classList_search($classID,'',$session);
//$class_list2 = class_list_view($session,$classID,$StudentID);
$noClass = count($class_list);
//echo $noClass;
$student = student_view_1('','');
$classview = class_view($classID);
$classRoom = $classview[0];
$timetable = timeTable_view_s($classID);
$subjects = subject_view_1('');
$sectionID = $classRoom->getSectionID();
$format_view = array();
//$subjectID = '';
//$StudentID = '';
$section = section_display($sectionID);
$assessment = assessment_display($section->getAssessmentID());
$grading = grading_display($section->getGradingID());
if($grading != null)
$grading_format_view = grading_format_view($grading->getGradingID(),'');
$assessment = section_assessment_view($sectionID,$session,$term);
$ass_id = $assessment[0]['assessment_format_id'];
if(count($assessment)<1){
echo "No Assessment chosen for this section";
}
else {
$format_view = assessment_format_view_clone($ass_id);
}
$scores = scores_view('');
//$result_view = result_view($subjectID,$StudentID,$classID);
$result_view = result_view_students($class_list,$session,$term);
$stud = getSubjectResults($result_view,$format_view,$scores);
$traits_view_section = traits_view_section($sectionID);
$traits = traits_view_s($session,$term,$section->getSectionID());
$staff_view = staff_display($classRoom->getFormTeacher(),'');
$rs = getFormattedStudent($result_view,$format_view,$scores);
$divider = 'ByClass';
$timetable_viewnew = timeTable_view($classID,'');
$check[] = '';
for($i=0;$i<count($timetable_viewnew);$i++)
{
$subjectID1 = $timetable_viewnew[$i]->getSubjectID();
$tag1 = $timetable_viewnew[$i]->getTag();
//if($tag=='Ancillary')
$check[] = $tag1;
}
if(in_array("Ancillary",$check)){
$divider = 'ByStudent';
}
//$html = '
?>
<style type="text/css">
* {
}
.page {
width: 21cm;
min-height: 26cm;
margin: 0.2cm auto;
}
.subpage {
padding: 0.1cm;
}
#page {
size: A4;
margin: 0;
}
#media print {
.page {
margin: 0;
width: initial;
min-height: initial;
page-break-after: always;
}
}
.rsBox
{
width: 100%;
margin-right: auto;
margin-left: auto;
border: 1px solid #666666;
border-image:url(img/border.png) 30 30 round;
-moz-border-image:url(img/border.png) 30 30 round; /* Firefox */
-webkit-border-image:url(img/border.png) 30 30 round; /* Safari and Chrome */
-o-border-image:url(img/border.png) 30 30 round; /* Opera */
padding:5px;
overflow:hidden;
}
.block
{
width: 95%;
margin-right: auto;
margin-left: auto;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #666666;
}
.seperator
{
height: 20px;
}
.name
{
height: 43px;
width: 100%;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight:bolder;
padding-top: 5px;
padding-bottom: 5px;
text-transform:uppercase;
}
.motto
{
height: 20px;
width: 100%;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
padding-top: 5px;
padding-bottom: 5px;
}
.address
{
height: 20px;
width: 95%;
font-family: Verdana, Arial, Helvetica, sans-serif;
padding-top: 0px;
font-size: 12px;
padding-bottom: 2px;
}
.session
{
height: 20px;
width: 100%;
font-family: Verdana, Arial, Helvetica, sans-serif;
padding-top: 5px;
font-size: 12px;
padding-bottom: 5px;
}
.over_border
{
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333333;
}
.section1 td
{
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
border:1px solid #999;
}
.overview td
{
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333333;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333333;
}
.trait .td
{
border-width: 1px;
border-style: solid;
border-color: #333333;
}
.ob
{
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
}
.tob
{
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
}
.obs
{
font-size: 11px;
font-family: Arial, Helvetica, sans-serif;
}
.subjectsDiv {
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
width:100px;
height:100%;
text-align:left;
padding:0px;
background:#FFF;
}
.subjectsDivTd {
height:100px;
max-width:20px;
min-width:20px;
border:1px solid;
overflow:hidden;
margin:0px;
padding:0px;
background:#000;
}
</style>
<div class="book">
<?php
$newsletter = '';
$data = newsletter_view('',$sectionID,$session,$term);
for($i=0; $i<count($data); $i++){
$newsletter = $data[$i]['content'];
}
$i = 0;
if(empty($class_list)){
echo "No class member";
}
else
foreach($class_list as $std):
//$i++;
//if($i>10)
//break;
$StudentID = $std->getStudentID();
if($student[$StudentID]==NULL){
continue;
}
$cAverage = 0.0;
$totalScore = 0.0;
$fAverage = 0.0;
$hAverage = 0.0;
$lAverage = 0.0;
$index = 0;
$results = $result_view[$std->getStudentID()];
$index = 0;
$noSubjects = 0;
if(!empty($results))
foreach($results as $result)
{
$resultID = $result->getResultID();
$mark = 0;
$totality = 0;
$subjectID = trim($result->getSubjectID());
if(!empty($stud[$subjectID]))
$subject = $stud[$subjectID];
if(!empty($format_view)):
foreach($format_view as $format):
if(isset($scores[$resultID][$format->getFormatID()]))
{
$score = $scores[$resultID][$format->getFormatID()];
$mark = $score->getScore();
$totalScore += $mark;
}
endforeach;
endif;
$index++;
$cAverage += getSubjectAverage($subject,$noClass);
}
if(!empty($cAverage))
$cAverage /= $index;
if(!empty($fAverage))
$fAverage = $totalScore / $index;
$formatting = getGradeFormat($grading_format_view,round($fAverage,0));
$grade = 'N/A';
if($formatting != null)
$grade = $formatting->getDescriptor();
//$html .=
$comment = comment_view($StudentID,$session,$term);
for($l=0; $l<count($comment); $l++){
$cc = $comment[$l];
$formteacher_comment = $cc->getFormteacher();
$principal_comment = $cc->getPrincipal();
}
$bscores = count($results);
$cscores = $bscores * 100;
if(!empty($totalScore))
//$percentage = round($totalScore/$cscores * 100,0)."%";
echo $cscores;
$percentage = round($totalScore/$cscores * 100,2);
if($divider=="ByStudent") {
$percentage = round($totalScore/$cscores * 100,2);
}
else {
$percentage = round($totalScore/count($timetable_viewnew),2);
};
//$totalScore/$cscores * 100;
?>
<a href='#' onclick='window.print()'><img src='images/print_icon.jpg' width='50' height='30' /></a>
<div class="page">
<div class="subpage">
<div class="rsBox">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr style="height:auto;">
<td height="" align="center" >
<div style="width:auto; height:auto; overflow:auto; border-bottom:1px solid;">
<div style="border:0px solid; width:10%; height:100px; float:left; padding-top:10px;padding-bottom:10px; ">
<img src="<?php echo $config->getLogo(); ?>" style="width:100%; height:100%;" />
</div>
<div style="border:0px solid; width:78%; float:left;">
<h4 style="margin-bottom:0px; margin-top:0px;">ARCHDIOCESE OF ONITSHA</h4>
<div class="name"><?php echo $config->getSchoolname(); ?></div>
<div class="address"><?php echo $config->getAddress(); ?></div>
<div class="session"> REPORT SHEET FOR <?php echo $term . ', ' . $session ; ?> ACADEMIC SESSION</div>
</div>
<div style="border:0px solid; width:10%; height:100px; float:left; padding-top:10px;padding-bottom:10px; ">
<img src="images/micolos.jpg" style="width:100%; height:100%;" />
</div>
</div>
</td>
</tr>
<tr>
<td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="2" class="section1">
<tr>
<td width="19%" align="left" style="font-weight:bold;">NAME::</td>
<td width="1%" align="right"> </td>
<td width="43%"><?php echo $student[$StudentID]->getFirstname(). ' ' .$student[$StudentID]->getMiddlename().' '. $student[$StudentID]->getLastname(); ?></td>
<td width="20%" align="left" style="font-weight:bold;">Mark Obtainable: </td>
<td width="1%" align="right"> </td>
<td width="16%"><?php echo $cscores ;?></td>
</tr>
<tr>
<td align="left" style="font-weight:bold;">CLASS::</td>
<td align="right"> </td>
<td><?php echo $classRoom->getLevel() . ' ' . $classRoom->getPrefix(); ?></td>
<td align="left" style="font-weight:bold;">Total:: </td>
<td align="right"> </td>
<td><?php echo $totalScore; ?></td>
</tr>
<tr>
<td align="left" style="font-weight:bold;">Admission No:: </td>
<td align="right"> </td>
<td><?php echo $student[$StudentID]->getRegno(); ?></td>
<td align="left" style="font-weight:bold;">Average:</td>
<td align="right"> </td>
<td><?php if(!empty($percentage)) echo $percentage; ?> </td>
</tr>
<tr>
<td align="left" style="font-weight:bold;">Session::</td>
<td align="right"> </td>
<td><?php echo $session; ?></td>
<td align="left" style="font-weight:bold;">Position:</td>
<td align="right"> </td>
<td> <?php
echo getTermPosition($rs,$StudentID);
$pos = getTermPosition($rs,$StudentID);
if($pos == '11'){
echo 'th';
}
elseif($pos == 12){
echo 'th';
}
elseif($pos == 13){
echo 'th';
}
elseif(substr($pos, -1)=='1') { echo 'st'; }
else if(substr($pos, -1)=='2') { echo 'nd'; }
else if(substr($pos, -1)=='3') { echo 'rd'; }
else { echo 'th'; }
?></td>
</tr>
<tr>
<td align="left" style="font-weight:bold;">Term:</td>
<td align="right"> </td>
<td><?php echo $term; ?></td>
<td align="left" style="font-weight:bold;"> </td>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="left" style="font-weight:bold;">Next Term Begins</td>
<td align="right"> </td>
<td><?php echo $current_session->getNextTerm(); ?></td>
<td align="left" style="font-weight:bold;"> </td>
<td align="right"> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td>
<div class="block"><span style="font-weight:bold;">No. in Class :: <?php echo $noClass; ?></span></div>
</td>
</tr>
<tr>
<td>
<div class="block">
GRADE: <br />
<?php
foreach($grading_format_view as $b) {
$desc = $b->getDescriptor();
$start = $b->getStart();
$end = $b->getEnd();
echo '<b>'.$desc.'</b>'.'='.$start.'-'.$end.','.' ';
}
?>
</div>
</td>
</tr>
<tr>
<td>
<div class="block">
<table border="0" width="100%" cellspacing="0" class="overview">
<tr class="ob">
<td align="center" width="25%">SUBJECT</td>
<?php
if(!empty($format_view)):
foreach($format_view as $format):
?>
<!-- // $html .= -->
<td valign="bottom" align="center"> <?php echo $format->getShortName(); ?><br>
<?php echo '('. $format->getPercentage() . '%)'; ?></td>
<?php
endforeach;
endif;
// $html .=
?>
<td valign="bottom" align="center">TOTAL</td>
<!-- <td valign="bottom" align="center">POSITION</td>-->
<td valign="bottom" align="center">GRADE </td>
<td align="center" valign="bottom" style="width:120px;">COMMENT</td>
<td valign="bottom" align="center">Subject Master Signature</td>
</tr>
<?php
if(!empty($results))
foreach($results as $result)
{
$subjectID = $result->getSubjectID();
//if($timetable[$subjectID]->getTag()!='Compulsory')
//{
//continue;
//}
$subject = $stud[$subjectID];
arsort($subject);
$noSubjects++;
$index++;
$resultID = $result->getResultID();
$mark = "";
$totality = 0;
//$html .=
?>
<tr class="obs">
<td align="left"> <?php if(!empty($subjects[$subjectID])) { echo $subjects[$subjectID]->getTitle(); } else { echo $subjectID; } ?> </td>
<?php
$mark = '-';
if(!empty($format_view)):
foreach($format_view as $format):
if(isset($scores[$resultID][$format->getFormatID()]))
{
$score = $scores[$resultID][$format->getFormatID()];
if(empty($score)){
$mark = '-';
}
else {
$mark = $score->getScore();
}
$totality += $mark;
$totalScore += $mark;
}
?>
<!-- // $html .= -->
<td align="center"> <?php echo $mark; ?> </td>
<?php
endforeach;
endif;
$formatter = getGradeFormat($grading_format_view,$totality);
// $html .=
?>
<td align="center"><?php echo $totality; ?></td>
<!-- <td align="center"><?php //echo getSubjectPosition($subject,$resultID) ; ?></td>-->
<td align="center"><?php echo $formatter->getDescriptor(); ?></td>
<td align="center"><?php echo $formatter->getComment(); ?></td>
<td>.</td>
</tr>
<?php
}
if(!empty($totalScore))
$average = $totalScore/ $noSubjects;
//$html .=
?>
</table>
</div></td></tr>
<tr><td>
<div class="block">
<table width="100%" align="center" cellpadding="0" cellspacing="0" class="trait" style="float:left; border:0px;">
<tr>
<td style="border:0px;">
<!-- Rating Details::-->
<?php
$trait_rating_view = view_section_traits(view_section_trait_rating_format($sectionID));
//echo $trait_rating_view;
for($j=0; $j<(count($trait_rating_view)); $j++){
$trait_rating_s = $trait_rating_view[$j];
?>
<b>
<?php
//echo $trait_rating_view[$j]['rating'];?></b><!--=--><?php //echo $trait_rating_view[$j]['description'].','.' '; ?>
<?php
}
?>
</td>
</tr>
<tr class="tob" style="border:0px;" >
<td style="border:0px;">
<table>
<tr>
<td >
<?php
if(!empty($traits))
foreach($traits as $format):
?>
<div style="min-width:180px; min-height:80px; border:0px solid; float:left; position:relative; margin-right:4px;" >
<table border="1" style="max-width:180px; border:1px solid #CCC;">
<tr>
<td style="font-size:11px; font-weight:bold; text-transform:uppercase;"><?php echo $format->getTraitDesc(); ?></td> <?php
$t_format_view = traits_definition_view($format->getTriatID());
if(!empty($t_format_view)):
for($u=0; $u<count($t_format_view); $u++):
$t_format = $t_format_view[$u];
// $traits_rating_format =
//$rating = get_student_trait_rating($StudentID,$t_format->getTraitID(),$t_format->getTraitDefinitionID())
?>
<td style="font-size:11px;" class="subjectsDivTd"><div class="subjectsDiv"> <?php echo $t_format->getDefinition(); ?></div> </td>
<?php
endfor;
endif;
?>
</tr>
<tr>
<td style="font-size:11px; font-weight:bold; text-transform:uppercase;">Rating</td><?php
$t_format_view = traits_definition_view($format->getTriatID());
if(!empty($t_format_view)):
for($u=0; $u<count($t_format_view); $u++):
$t_format = $t_format_view[$u];
// $traits_rating_format =
//$rating = get_student_trait_rating($StudentID,$t_format->getTraitID(),$t_format->getTraitDefinitionID())
?>
<td><?php
if(get_student_trait_rating($StudentID,$t_format->getTraitID(),$t_format->getTraitDefinitionID(),$session,'Third Term')==NULL){ echo " ";}
else { get_student_trait_rating($StudentID,$t_format->getTraitID(),$t_format->getTraitDefinitionID(),$session,'Third Term'); } ?> </td>
<?php
endfor;
endif;
?>
</tr>
</table>
</div>
<?php
endforeach;
?>
</td>
</tr>
</table></td></tr></table></div>
<tr>
<td>
<div class="rsBox">
<table width="100%" align="center" cellpadding="0" cellspacing="0" class="trait" style="float:left;" border="1">
<tr class="tob">
<td style="max-width:80px;"><strong>Class Manager:</strong></td>
<td colspan="4" align="center"><?php if(!empty($staff_view)){echo $staff_view->getTitle().' '.$staff_view->getFirstname().' '.$staff_view->getMiddlename().' '.$staff_view->getLastname();} else { echo ".";} ?></td>
</tr>
<tr class="tob">
<td style="max-width:80px;"><strong>Class Manager Remark:</strong></td>
<td colspan="4" align="center"><?php if(!empty($formteacher_comment)){ echo $formteacher_comment; } else { echo ".";} ?></td>
</tr>
<tr class="tob">
<td style="max-width:80px;"><strong>School Head Remark</strong>:</td>
<td colspan="4" align="center"><?php if(!empty($principal_comment)) { echo $principal_comment; } else { echo ".";} ?></td>
</tr>
<tr class="tob">
<td style="max-width:80px;"><strong>School Head/Principal</strong>:</td>
<td colspan="4" align="center"><?php echo
$section->getSectionHead(); ?></td>
</tr>
<tr class="tob">
<td style="max-width:80px;"><strong>School Head/Principal Signature</strong>:</td>
<td colspan="4" align="center"><img src="<?php echo $section->getSectionHeadSignature(); ?>" width="120" height="40" /></td>
</tr>
</table>
</div>
</td></tr>
</table>
</div>
</div>
</div>
<div class="seperator"></div>
<?php
if($newsletter==""){
continue;
}
else {
?>
<div class="book">
<div class="page" style="height:300xp;">
<div class="subpage">
<div class="rsBox">
<?php
echo $newsletter;
?>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
endforeach;
//$html .=
?>
</div>
<?php
/*if($_REQUEST['op'] == 'PDF' )
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream($classRoom->getLevel() .' ' . $classRoom->getPrefix() . ' ' . "result.pdf");
}
else
{
echo $html;*/
?>
<?php
//}
?>
<script type="javascript">
window.print();
</script>
I am using this code to add some buttons with shortcode in functions.php## Heading ## then it is working :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<p><b>Setup/Medicine Download<b></p>[maxbutton id="1"]';
$content .= '[maxbutton id="2"]';
$content .= '[maxbutton id="3"]';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
But when I add some Html code after that then it does not work :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">About Author</span> </b>
<input type="hidden" name="stats" value="2498">
</h3>you can be an author too, join mhktricks and show you skills</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="http://mhktricks.net/user-registration/" target="_blank">
<input class="p2graybtn" style="height: 26px; width:150px;" type="button" value="Join Us">
</a>
</td>
</tr>
</tbody>
</table>
<hr>
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<?php echo get_avatar( get_the_author_meta( 'user_email' ), 70 ); ?>
</td>
<td style="border: solid 1px #ffffff;">
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<span style="color: #555;font-size:20px;font-family: Open Sans;font-weight: 400;font-style: normal;text-decoration: none;">
<?php echo get_the_author(); ?>
</span>
<br><div style="margin-left:1px;">
<?php echo get_author_role(); ?>
<span style="position:relative;top:1px;margin-left:5px;"><img src="http://i2.wp.com/codex.onhax.net/img/verified.png" height="12" width="12"></span>
</div>
</td>
<td style="border: solid 1px #ffffff;">
<div style="margin-left: 3px;margin-top: -17px;border: #B8B8B8 1px solid;border-radius:2px;padding: 0px 5px 0px 5px;font-size:10px;">
<?php the_author_posts(); ?> POSTS</div>';
</td>
</tr>
</tbody>
</table><div style="margin-top:-12px;">
</div>
<div style="margin-left:3px;margin-top:2px;padding-right:60px;">
<?php the_author_meta( 'description' ); ?>
<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
View all posts by me
<?php get_the_author(); ?>
<span class="meta-nav">→</span>
</a>
</div>
</td>
</tr>
</tbody>
</table>
<hr color="white">
<hr color="white">
<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">Discussion</span></b></h3>
share your knowledge.mind to help others</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="#" class="show-comments">
<input class="p2graybtn" style="height: 26px;" type="button" value="Toggle Comments">
</a>
</td>
</tr>
</tbody>
</table>';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
When I add the above code the page even doesn't load.
I just want to add author box below posts but it does not work. Help Please !
If you'd bothered to look, you have a ' in your html, which is terminating your string assignment:
[...long snip...] the_author_posts(); ?> POSTS</div>';
^---
</td>
which turns that </td> into PHP code, causing a fatal parse error.
This is why massive multi-line strings like this are a horrible idea. If you need to dump text like that, use a HEREDOC, or drop out of PHP mode. e.g.
$content = <<<EOL
blah blah blah all your html here blah blah blah
EOL;
HEREDOCs removes the need to worry about quotes.
You should also turn on display_errors and error_reporting, which would have told you about the fatal error. They should NEVER be off on a devel/debug system.
The code I used doesn't give me any MySQL errors (which is good)
Except it won't display the results I was looking for (in the url bar it looks like this search.php?departure_label=Dar+Es+Salaam&arrival_label=Zanzibar&txtDate1=03%2F19%2F2012&txtDate2=03%2F20%2F2012&ddlPAxADT=1&ddlPaxCHD=0&ddlPaxINF=0&search=Submit which is what I wanted since it means all of the information was passed through)
It just displays a white screen
Here's the code
<?PHP
$button = $_GET['submit'];
$search = $_GET['search'];
$sfrom = $_GET['departure_label'];
$sfromda = $_GET['txtdate1'];
$sto = $_GET['arrival_label'];
$stoda = $_GET['txtdate2'];
$padt = $_GET['ddlPaxADT'];
$pchd = $_GET['ddlPaxCHD'];
$pinf = $_GET['ddlPaxINF'];
include "connection.php";
$result=mysql_query("SELECT * from search_v where rout_from like'".$sfrom."' and rout_to like'".$sto."' and DATE_FORMAT(date_avialable,'%Y-%m-%d') between'".$sfromda."' and '".$stoda."' LIMIT 10") or die(mysql_error());
while($runrows = mysql_fetch_assoc($result)){
$flightid = $runrows['flight_id'];
$aseats = $runrows['seats_avialable'];
$todate = strftime("%b %d, %Y %l:%M %p" ,strtotime($runrows['to_date']));
$date = strftime("%b %d, %Y %l:%M %p" ,strtotime($runrows['date_avialable']));
$from = $runrows['rout_from'];
$to = $runrows['rout_to'];
$acost = $runrows['adult_cost'];
$ccost = $runrows['child_cost'];
$cur = $runrows['currency'];
$oth = $runrows['other_cost'];
echo "";
?>
<li class="item clearfix"> <span
id="cntntMiddle_ctl01_rptmain_lblFromt_0">
<table cellpadding="0" cellspacing="0">
<thead><tr>
<th class="price">Price</th>
<th>From</th>
<th>To</th>
<th>Depart</th>
<th>Arrive</th>
</tr>
</thead><tfoot> <tr>
<td><a class="more" href="#">Full
Details</a></td>
<td colspan="6">
<div class="select-wrap">
<p class="seats"><strong><?php echo $aseats; ?></strong> <span>seats
left</span> <em>at this price</em></p>
<button class="btn-select" type="button"
onclick='return ray.ajax("#");'>Select Flight</button></div>
</td>
</tr>
</tfoot><tbody>
<tr>
<td class="price" rowspan="2"><a
style="font-weight: bold; cursor: pointer; text-decoration: none;"
herf="#" onclick='return ray.ajax("#");'><span
style="font-size: 24px; font-weight: bold;"><?php echo $totalcost; ?></span><span
style="font-size: 11px; margin-top: 2px; display: block; color: rgb(255, 255, 255); text-align: center; font-weight: normal;">per
adult</span><span
style="font-size: 12px; margin-top: 2px; display: block; color: rgb(255, 255, 255); text-align: center; font-weight: normal;">(with fees)</span></a></td>
<td><?php echo $from; ?></td>
<td><?php echo $to ?></td>
<td style="padding-right: 2px;">4:05 PM</td>
<td>7:05 PM</td>
</tr>
</tbody>
</table>
</span> <a
id="cntntMiddle_ctl01_rptmain_lblResultDetails1_0" title="1"
href="javascript:__doPostBack('ctl00$cntntMiddle$ctl01$rptmain$ctl00$lblResultDetails1','')"
style="color: Black;"></a><a class="close"
href="#">Close</a>
<div class="info clearfix">
<div class="info clearfix">
<h4>Departing Flight</h4>
<ul class="clearfix">
<li>
<h5><?php echo $from; ?> to <?php echo $to; ?> <?php echo $date; ?></h5>
<ul>
<li> </li>
<li><strong>Flight #</strong> - <?php echo $flightid; ?></li>
<li><strong>Departure Time – </strong>
6:05 PM</li>
<li><strong>Arrival Time</strong> - 5:05 PM</li>
</ul>
</li>
</ul>
<ul>
<li style="padding-top: 5px;"><span
style="color: rgb(212, 22, 13); font-weight: bold; font-size: 11px; text-decoration: none;">
Fare Breakdown</span> </li>
</ul>
<table class="more">
<tbody>
<tr>
<th>Passenger</th>
<th>Fare</th>
<th> Taxes and Fees</th>
<th>Qty</th>
<th>Total Cost</th>
</tr>
</tbody><tbody>
<tr>
<td>Adult</td>
<td
style="color: rgb(100, 100, 100); font-size: 11px; font-weight: bold;"><?php echo $acost; ?></td>
<td><?php echo $oth; ?></td>
<td id="paxAdtTd">1</td>
<td><?php echo $totaladult; ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Cost of Sale(<?php echo $cur; ?>)</td>
<td> </td>
<td
style="color: rgb(100, 100, 100); font-size: 14px; font-weight: bold;"><?php echo $totaladult; ?></td>
</tr>
</tbody>
</table>
<br />
<span style="font-weight: bold; padding-top: 10px;">
*Additional airline fees for baggage may apply</span>
<div class="select-wrap">
<p class="seats"><strong><?php echo $aseats; ?></strong> <span>seats
left</span> <em>at this price</em></p>
<button class="btn-select" type="button"
onclick='return ray.ajax("https://res.website.com/checkout.aspx?recommendation=1&subset=1&supplier=53&page=flightconfirm",1,this);'>Select
Flight</button></div>
<?php
}
?>
$result=mysql_query("SELECT * from search_v where rout_from like %'".$sfrom."'% and rout_to like %'".$sto."'% and DATE_FORMAT(date_avialable,'%Y-%m-%d') between'".$sfromda."' and '".$stoda."' LIMIT 10") or die(mysql_error());
there were two (logical?) errors, with LIKE function, you didn't use a wildcard % key, and in next LIKE occurance, for $sto you didn't provide a blankspace.