Convert From PHP and PDF - php

I need to convert from Php(html Table) to Pdf. I have used the DOM PDf for the conversion. But i didn't get the proper view in pdf. please find the below images.
Pdf View
HTML View
Code Below:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<?php if(count($this->userDetails)>=1){ for($a=0;$a<count($this->userDetails);$a++){ $user = $this->userDetails[$a]; ?>
<body>
<div style="background-image: url(http://192.168.2.26/skins/schooladmin/images/id_bg.png); background-repeat: repeat; width:400px; height:220px;margin:10px 0px 0px 10px;float:left;position:relative;">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; color:#fff; background-image:url(http://192.168.2.26/skins/schooladmin/images/id_white_bg.png); background-repeat:no-repeat;" width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td style="background-image: url(http://192.168.2.26/skins/schooladmin/images/schoollogo.png); background-repeat:no-repeat; width:36px; height:61px;"> </td>
<td colspan="2"><?php echo $this->schoolDetails['name'] ?></td>
</tr>
<?php
if($user){
$user['userdetails']['name'] = $user['userdetails']['firstname'].$user['userdetails']['lastname'];
$photoPath = BASE_PATH."/uploads/photos/student/".$user['userdetails']['photo'];
if(!file_exists($photoPath)){
$photoPath = BASE_PATH."/skins/schooladmin/images/id_photo.png";
}
}else{
$photoPath = BASE_PATH."/skins/schooladmin/images/id_photo.png";
}
?>
<tr>
<td style="background-image: url(<?php echo $photoPath; ?>); background-repeat:no-repeat; width:82px; height:82px;"> </td>
<td colspan="2">
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" >
<?php if($this->templateDetails['template']){
for($i=0;$i<1;$i++){
for($j=0;$j<count($this->templateDetails['template_details']);$j++){
if($this->templateDetails['template_details'][$j]['type'] == "text" && $this->templateDetails['template_details'][$j]['page'] == "front"){
?>
<tr>
<td width="38%"><?php echo $this->templateDetails['template_details'][$j]['label']; ?></td>
<td width="62%"><?php echo #$user['userdetails'][$this->templateDetails['template_details'][$j]['field']]; ?></td>
</tr>
<?php } } } } ?>
</table>
</td>
</tr>
<tr>
<td colspan="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" align="center"><?php echo $this->schoolDetails['address'] ?>, <?php echo $this->schoolDetails['address2'] ?>, <?php echo $this->schoolDetails['city'] ?> - <?php echo $this->schoolDetails['zipcode'] ?></td>
</tr>
<tr>
<td colspan="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" align="center">Ph: <?php echo $this->schoolDetails['contactno'] ?></td>
</tr>
</table>
</div>
<div style="background-image: url(http://192.168.2.26/skins/schooladmin/images/id_bg.png); background-repeat: repeat; width:400px; height:220px;margin:10px 0px 0px 10px;float:left;position:relative;">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; color:#fff; background-image:url(http://192.168.2.26/skins/schooladmin/images/id_white_bg.png); background-repeat:no-repeat;" width="100%" border="0" cellpadding="5" cellspacing="5">
<?php if($this->templateDetails['template']){
for($i=0;$i<1;$i++){
for($j=0;$j<count($this->templateDetails['template_details']);$j++){
if($this->templateDetails['template_details'][$j]['type'] == "text" && $this->templateDetails['template_details'][$j]['page'] == "back"){
?>
<tr>
<td width="38%"><?php echo $this->templateDetails['template_details'][$j]['label']; ?></td>
<td width="62%"><?php echo #$user['userdetails'][$this->templateDetails['template_details'][$j]['field']]; ?></td>
</tr>
<?php } } } } ?>
</table>
</div>
<?php } } ?>
</body>
</html>

I recommend not trying to massage your HTML so that it converts to PDF this way. You'll expend far to much effort tweaking things that can change when you switch rendering engines or even printers.
You'll have an easier time if you create your PDFs natively using FPDF or TCPDF. For example (just to get you started):
<?php
require_once('/path/to/tcpdf.php');
// misc variables
$lightblue = array(100, 100, 250);
$darkblue = array(0, 0, 255);
$white = array(255, 255, 255);
// prepare new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetFont('helvetica', 'B', 20);
// add a page
$pdf->AddPage();
// set the coordinates of the gradient
$coords = array(0, 1, 1, 0);
// paint a linear gradient
$pdf->LinearGradient(20, 45, 105, 60, $lightblue, $darkblue, $coords);
// write text
$pdf->SetTextColorArray($white);
$pdf->Text(40, 50, 'hello');
$pdf->Text(40, 60, 'world');
// Close and output PDF document
$pdf->Output('tkexample.pdf', 'I');

For geeting 100% same view, use php fpdf library.You can get all the supports, tutorials and download from here

Related

Scrollable Echo DB Table with Fix header

I'm trying to make a scrollable table with fix header. This works well if the data is entered to HTML, but when I try to echo content of my database to the table, the scroll bar messes up and my header is no longer fixed. As seen in the photo, the scroll bar is on each table entry. I've tried .div wrapping up the table body as some did but it doesn't work.
body{
background: lightblue;
}
#tble th {
text-align: left;
background-color: green;
color: white;
}
table{
display: block;
border: 1px solid;
margin-top: 10px;
width: 350px;
}
tbody{
display: block;
height: 50px;
overflow-y: scroll;
}
th {
width: 75px;
}
td {
width: 75px;
}
<html lang="en">
<body>
<table align="center" id="tble">
<thead>
<th style="text-align: center">ID</th>
<th style="text-align: center">Username</th>
<th style="text-align: center">Rights</th>
<th style="text-align: center">Age</th>
</thead>
<tbody>
<tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "account");
$result = mysqli_query($conn, "SELECT * FROM account.log WHERE rights IN ('Admin','User')", MYSQLI_USE_RESULT) or die(mysql_error());
while($row = mysqli_fetch_array( $result )) {
?>
<td style="text-align: center"><?php echo $row['id']; ?></td>
<td style="text-align: center"><?php echo $row['user']; ?></td>
<td style="text-align: center"><?php echo $row['rights']; ?></td>
<td style="text-align: center"><?php echo $row['age']; ?></td>
</tr>
</tbody>
<?php
}
?>
</body>
</table>
Is there something I missed? Hoping someone could point me to the right direction.
<!-- language: lang-html -->
<html lang="en">
<body>
<table align="center" id="tble">
<thead>
<th style="text-align: center">ID</th>
<th style="text-align: center">Username</th>
<th style="text-align: center">Rights</th>
<th style="text-align: center">Age</th>
</thead>
<tbody>
<tr>//move this from here
<?php
$conn = mysqli_connect("localhost", "root", "", "account");
$result = mysqli_query($conn, "SELECT * FROM account.log WHERE rights IN ('Admin','User')", MYSQLI_USE_RESULT) or die(mysql_error());
while($row = mysqli_fetch_array( $result )) {
?>
<tr> //to here
<td style="text-align: center"><?php echo $row['id']; ?></td>
<td style="text-align: center"><?php echo $row['user']; ?></td>
<td style="text-align: center"><?php echo $row['rights']; ?></td>
<td style="text-align: center"><?php echo $row['age']; ?></td>
</tr>
</tbody>
<?php
}
?>
</body>
</table>

Display header and footer in every page is breaks by long table

I want to set all header and footer in all page in a pdf with mpdf,
So, my code looked like this :
<!DOCTYPE html>
<html>
<head>
<title>Data Category</title>
<style type="text/css">
.page{
padding-top:2.5cm;
padding-right:1.5cm;
padding-left:1cm;
padding-bottom:5cm;
}
table{
border-spacing:0;
border-collapse: collapse;
width:100%;
page-break-inside:auto;
}
table td, table th{
border: 1px solid black;
}
</style>
</head>
<body>
<div class="page">
<table border="0">
<thead>
<tr>
<th>No</th>
<th>Tanggal</th>
<th>Jam</th>
<th>No struk</th>
<th>Nama</th>
<th>Quantity</th>
<th>Nama Item</th>
<th>Harga Jual</th>
<th>Sub total</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach ($data as $key => $value) {
?>
<tr>
<td><?= $no++ ?></td>
<td><?= $value['date_format'] ?></td>
<td><?= $value['jam'] ?></td>
<td><?= $value['struk_no'] ?></td>
<td><?= $value['nama_karyawan'] ?></td>
<td><?= $value['jumlah_jual'] ?></td>
<td><?= $value['nama_item'] ?></td>
<td><?= $value['harga_jual'] ?></td>
<td><?= $value['subtotal'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
I have alread read their docs from here : mpdf docs.
But, when my table is loaded more than one page, the table breaks the header:
$detail = Yii::$app->db->createCommand($this->getSqlReportDetail($parseStart, $parseEnd))->queryAll();
$html = $this->renderPartial('_report_detail', ['data' => $detail]);
$mpdf = new \mPDF('c', 'A4', '', '', 0, 0, 0, 0, 0, 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->SetHTMLHeader(''
. '<div style="text-align: center; font-weight: bold;">'
. '<h1>Hair Deeper Salon</h1><br>'
. '<hr>'
. '</div>'
);
$mpdf->SetHTMLFooter('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;">
<tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE j-m-Y}</span></td>
<td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
<td width="33%" style="text-align: right; ">My document</td>
</tr>
</table>
');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
This is the document right now :
Try using this before setting header and footer
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';

dompdf Image overlapping text pdf generating issue

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.

Internal Server on a dynamic php script that works well on other options

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>

pagination - not working

I don't understand why my pagination is not working! It is displaying ok by default, but When click on 'Next' page or some page number nothing happens, not changing page at all. It's like not recognizing pagination.js or pagination_class.php.
I have another part of site where it is working fine, so not sure did I miss something obvious here?
In same folder have 4 files concerning this:myaccount_betinghistory.php, myaccount_bettinghistory_sub.php, pagination.js, pagination_class.php.
Here are all the codes of those files to have everything to look in, I hope you will be able to find bug there!
myaccount_bettinghistory.php:
<?php
error_reporting(E_ALL^E_NOTICE);
include('pagination_class.php');
?>
<script language="JavaScript" src="pagination.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<?PHP
//Session start
#session_start();
//Path to root
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
//Require Init
$mode = array();
$mode[] = 'nohtml';
require_once $root . "/inc/php/init.php";
{
?>
<?PHP
}
?>
<?
$qry = "
SELECT timelive,bidprice,match_title,selection,winnings_with_startamount,odds,odds*10 AS gainedodds,username,
CASE
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status LIKE 'E' THEN 'pending'
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status NOT LIKE 'E' THEN 'active'
WHEN each_bid_recorded_Part2.result liKE each_bid_recorded_Part2.selection THEN 'WON'
WHEN each_bid_recorded_Part2.result NOT liKE each_bid_recorded_Part2.selection THEN 'LOST'
END AS result
FROM each_bid_recorded_Part2 WHERE each_bid_recorded_Part2.username LIKE '" . $_SESSION['username'] . "'
";
$qry .= " ORDER BY timelive DESC";
//for pagination
$starting=0;
$recpage = 4;//number of records per page
$obj = new pagination_class($qry,$starting,$recpage);
$result = $obj->result;
function getStyleColorForStatus($status) {
if ($status == 'WON') {
return '#99ff99';
}
else if ($status == 'LOST') {
return '#ff9999';
}
else if ($status == 'pending') {
return '#e5e5e5';
}
else if ($status == 'active') {
return '#ffffcc';
}
return '';
}
?>
<div>
<div class="pageTop"><img src="images/icons/faqicon.png" width="37" height="37" align=absbottom> Betting History</div>
<tr>
<td> </td>
</tr>
</div>
<div>
<p style="font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #535252; text-align: left;">Check your bets with you as a last bidder.</p>
</div>
<table width="600" border="0" cellspacing="0" cellpadding="0" style="font-size:11px; color: #535252;">
<form name="form1" action="myaccount_bettinghistory.php" method="POST" style="background-color:#f9f9f9; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1);">
<table border="0" align="left" width="500px" padding-left="0px" style="background:#F9F9F9;">
<tr><TD colspan="0">
<div id="page_contents">
<table width="755px" cellspacing="0" cellpadding="5" align="center" frame="box" rules="none" style="padding-bottom:2px; margin-bottom:0px; margin-top:3px; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1); border: 1px solid #cccccc;">
<tr style="height: 40px;">
<td width="30%" align="center" td class="winheader"><div class="glowtext">Event Start Time</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Bid Cost</div></td></td>
<td width="35%" align="center" td class="winheader"><div class="glowtext">Market/Event</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Selection</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winnings</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Odds</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Gained Odds</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winning Bidder</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Final Result</div></td></td>
</tr>
<?if(mysql_num_rows($result)!=0){
$counter = $starting + 1;
while($data = mysql_fetch_array($result)) {?>
<tr class="initial" onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'">
<td align="center"><font color="#333"><? echo $data['timelive']; ?></TD>
<td align="center">€ <? echo $data['bidprice']; ?></TD>
<td align="left"><font color="#0070c0"><? echo $data['match_title']; ?></TD>
<td align="left"><? echo $data['selection']; ?></TD>
<td align="center"><font color="green">€ <? echo $data['winnings_with_startamount']; ?></TD>
<td align="center"><? echo $data['odds']; ?></TD>
<td align="center"><? echo $data['gainedodds']; ?></TD>
<td align="center"><? echo $data['username']; ?></TD>
<td align="center" style="background-color:<?php echo getStyleColorForStatus($data['result']); ?>"><? echo $data['result']; ?></td>
</tr>
<?
$counter ++;
} ?>
<tr><TD align="center" colspan="10" style="padding-bottom:1px; padding-top:10px; color:#333;"><? echo $obj->anchors; ?></TD></tr>
<tr><TD align="center" colspan="10" style="padding-bottom:10px; padding-top:5px; color:#333;"><? echo $obj->total; ?></TD></tr>
<?}else{?>
<tr><TD align="center" colspan="10" style="padding-bottom:10px padding-top:10px; color:red;">No Data Found</TD></tr>
<?}?>
</TD></tr>
</table>
</div>
</tr>
</TD>
</form>
</table>
<STYLE>
*{ margin-bottom:0; }
#pagination-flickr li{
margin:0px;
padding:0px;
float:left;
font-size:10px;
}
#pagination-flickr a{
float:left;
padding:5px 7px;
margin-right:5px;
border:solid 1px #4d7dc5;
text-decoration:none;
background:#FFFFFF;
color:#4d7dc5;
font-size:10px;
}
#pagination-flickr .previous-off,
#pagination-flickr .next-off {
border:solid 1px #DDDDDD;
cursor:default;
background:#FFFFFF;
border:solid 1px #BBBBBB;
color:#BBBBBB;
padding:4px 6px;
margin-right:5px;
font-size:10px;
}
#pagination-flickr .next a,
#pagination-flickr .previous a {
background:#FFFFFF;
border:solid 1px #BBBBBB;
color:#BBBBBB;
font-size:10px;
}
#pagination-flickr .active{
cursor:default;
background:#4d7dc5;
color:#FFFFFF;
padding:4px 6px;
margin-right:5px;
border:solid 1px #4d7dc5;
font-size:10px;
}
#pagination-flickr a:link,
#pagination-flickr a:visited {
padding:4px 6px;
margin-right:5px;
border:solid 1px #4d7dc5;
background:#FFFFFF;
color:#4d7dc5;
font-size:10px;
}
#pagination-flickr a:hover{
padding:4px 6px;
margin-right:5px;
border:solid 1px #4d7dc5;
background:#ffc04a;
color:#000;
font-size:10px;
}
body,table
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
padding-bottom:5px;
empty-cells: show;
}
.glowtext
{
text-shadow: 0 0 20px white;
color:#333;
font-weight:bold;
}
</STYLE>
myaccount_bettinghistory_sub.php:
<?php
error_reporting(E_ALL^E_NOTICE);
include('pagination_class.php');
?>
<script language="JavaScript" src="pagination.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<?PHP
//Session start
#session_start();
//Path to root
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
//Require Init
$mode = array();
$mode[] = 'nohtml';
require_once $root . "/inc/php/init.php";
{
?>
<?PHP
}
?>
<?
$qry = "
SELECT timelive,bidprice,match_title,selection,winnings_with_startamount,odds,odds*10 AS gainedodds,username,
CASE
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status LIKE 'E' THEN 'pending'
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status NOT LIKE 'E' THEN 'active'
WHEN each_bid_recorded_Part2.result liKE each_bid_recorded_Part2.selection THEN 'WON'
WHEN each_bid_recorded_Part2.result NOT liKE each_bid_recorded_Part2.selection THEN 'LOST'
END AS result
FROM each_bid_recorded_Part2 WHERE each_bid_recorded_Part2.username LIKE '" . $_SESSION['username'] . "'
";
$qry .= " ORDER BY timelive DESC";
//for pagination
if(isset($_GET['starting'])&& !isset($_REQUEST['submit'])){
$starting=$_GET['starting'];
}else{
$starting=0;
}
$recpage = 4;//number of records per page
$obj = new pagination_class($qry,$starting,$recpage);
$result = $obj->result;
function getStyleColorForStatus($status) {
if ($status == 'WON') {
return '#99ff99';
}
else if ($status == 'LOST') {
return '#ff9999';
}
else if ($status == 'pending') {
return '#e5e5e5';
}
return '';
}
?>
<div>
<div class="pageTop"><img src="images/icons/faqicon.png" width="37" height="37" align=absbottom> Betting History</div>
<tr>
<td> </td>
</tr>
</div>
<div>
<p style="font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #535252; text-align: left;">Check your bets with you as a last bidder.</p>
</div>
<table width="600" border="0" cellspacing="0" cellpadding="0" style="font-size:11px; color: #535252;">
</div>
</div>
<table border="0" align="left" width="500px" padding-left="0px" style="background:#F9F9F9;">
<tr><TD colspan="0">
<div id="page_contents">
<table width="98%" cellspacing="0" cellpadding="5" align="center" frame="box" rules="none" style="padding-bottom:2px; margin-bottom:0px; margin-top:3px; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1); border: 1px solid #cccccc;">
<tr style="height: 40px;">
<td width="30%" align="center" td class="winheader"><div class="glowtext">Event Start Time</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Bid Cost</div></td></td>
<td width="35%" align="center" td class="winheader"><div class="glowtext">Market/Event</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Selection</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winnings</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Odds</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Gained Odds</div></td></td>
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winning Bidder</div></td></td>
<td width="5%" align="center" td class="winheader"><div class="glowtext">Final Result</div></td></td>
</tr>
<?if(mysql_num_rows($result)!=0){
$counter = $starting + 1;
while($data = mysql_fetch_array($result)) {?>
<tr class="initial" onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'">
<td align="center"><font color="#333"><? echo $data['timelive']; ?></TD>
<td align="center">€ <? echo $data['bidprice']; ?></TD>
<td align="left"><font color="#0070c0"><? echo $data['match_title']; ?></TD>
<td align="left"><? echo $data['selection']; ?></TD>
<td align="center"><font color="green">€ <? echo $data['winnings_with_startamount']; ?></TD>
<td align="center"><? echo $data['odds']; ?></TD>
<td align="center"><? echo $data['gainedodds']; ?></TD>
<td align="center"><? echo $data['username']; ?></TD>
<td align="center" style="background-color:<?php echo getStyleColorForStatus($data['result']); ?>"><? echo $data['result']; ?></td>
</tr>
<?
$counter ++;
} ?>
<tr><TD align="center" colspan="10" style="padding-bottom:1px; padding-top:10px; color:#333;"><? echo $obj->anchors; ?></TD></tr>
<tr><TD align="center" colspan="10" style="padding-bottom:10px; padding-top:5px; color:#333;"><? echo $obj->total; ?></TD></tr>
<?}else{?>
<tr><TD align="center" colspan="10" style="padding-bottom:10px padding-top:10px; color:red;">No Data Found</TD></tr>
<?}?>
</TD></tr>
</table>
</div>
</tr>
</TD>
</table>
pagination.js:
var xmlHttp
function pagination(page)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="myaccount_bettinghistory_sub.php";
url = url+"?starting="+page;
url = url+"&search_text="+document.form1.search_text.value;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("page_contents").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
pagination_class.php:
<?
/*
Developed by Reneesh T.K
reneeshtk#gmail.com
You can use it with out any worries...It is free for you..It will display the out put like:
First | Previous | 3 | 4 | 5 | 6 | 7| 8 | 9 | 10 | Next | Last
Page : 7 Of 10 . Total Records Found: 20
*/
class Pagination_class{
var $result;
var $anchors;
var $total;
function Pagination_class($qry,$starting,$recpage)
{
$rst = mysql_query($qry) or die(mysql_error());
$numrows = mysql_num_rows($rst);
$qry .= " limit $starting, $recpage";
$this->result = mysql_query($qry) or die(mysql_error());
$next = $starting+$recpage;
$var = ((intval($numrows/$recpage))-1)*$recpage;
$page_showing = intval($starting/$recpage)+1;
$total_page = ceil($numrows/$recpage);
if($numrows % $recpage != 0){
$last = ((intval($numrows/$recpage)))*$recpage;
}else{
$last = ((intval($numrows/$recpage))-1)*$recpage;
}
$previous = $starting-$recpage;
$anc = "<ul id='pagination-flickr'>";
if($previous < 0){
$anc .= "<li class='previous-off'><<</li>";
$anc .= "<li class='previous-off'><</li>";
}else{
$anc .= "<li class='next'><a href='javascript:pagination(0);'><< </a></li>";
$anc .= "<li class='next'><a href='javascript:pagination($previous);'>< </a></li>";
}
################If you dont want the numbers just comment this block###############
$norepeat = 4;//no of pages showing in the left and right side of the current page in the anchors
$j = 1;
$anch = "";
for($i=$page_showing; $i>1; $i--){
$fpreviousPage = $i-1;
$page = ceil($fpreviousPage*$recpage)-$recpage;
$anch = "<li><a href='javascript:pagination($page);'>$fpreviousPage </a></li>".$anch;
if($j == $norepeat) break;
$j++;
}
$anc .= $anch;
$anc .= "<li class='active'>".$page_showing."</li>";
$j = 1;
for($i=$page_showing; $i<$total_page; $i++){
$fnextPage = $i+1;
$page = ceil($fnextPage*$recpage)-$recpage;
$anc .= "<li><a href='javascript:pagination($page);'>$fnextPage</a></li>";
if($j==$norepeat) break;
$j++;
}
############################################################
if($next >= $numrows){
$anc .= "<li class='previous-off'>></li>";
$anc .= "<li class='previous-off'>>></li>";
}else{
$anc .= "<li class='next'><a href='javascript:pagination($next);'>> </a></li>";
$anc .= "<li class='next'><a href='javascript:pagination($last);'>>></a></li>";
}
$anc .= "</ul>";
$this->anchors = $anc;
$this->total = "Page : $page_showing of $total_page Total Records Found: $numrows";
}
}
?>
remove this
&& !isset($_REQUEST['submit'])
you are not using it !!!

Categories