pagination - not working - php

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 !!!

Related

update multi row php

i try to update a multi row like this
$ID = $_POST['ID'];
$size = count($_POST['compo']);
while ($i < $size) {
$compo = $_POST['compo'][$i];
$fill = $_POST['fill'][$i];
$query = "UPDATE Invantsion Set compon='".$compo."',Num='".$fill."' where ID='".$ID."'";
++$i;
}
the code on post is bulit from to parts..
<tr>
<td align="center"><span lang="he"><font size="2" face="Arial">
<?php
echo "<input type='hidden' name='compo[$i]' value='".$row['compon']."'>".$row['compon']."";
?>
</font></span>
</td>
<td>
<select name='fill[$i]' style="border: 1px solid #000000; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; background-color: #FFFFFF; font-family:Arial; font-size:8pt; font-weight:bold">
<?php
$Uid = $row['id'];
require( dirname( __FILE__ ) . '/com.php' );
echo "</select>";
}
?>
who getting the new data for mysql and the sec part who get the original data for MYSQL
while ($row = mysqli_fetch_array($result)) {
echo "<input type='hidden' name='ID' value='".$row['ID']."'>";
?>
<tr>
<td align="center"><span lang="he"><font size="2" face="Arial">
<?php
echo $row['compon'];
?>
</font></span>
</td>
<td align="center"><span lang="he"><font size="2" face="Arial">
<?php
echo $row['Num'];
?>
</font></span>
</td>
</tr>
what should be worng if i get error 500 or just the last result
UPDATE Invantsion Set compon='DECODERS',Num='' where ID='30'
and if i try to make the code looping only the words after set it no doing nothing at all..
any one?

how to while loop inside of a while loop as well as grouping the result if more than one of the result are matching

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 //////////////
?>

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.

While loop not displaying all results from query

I'm having problems showing all the results in my modal. There are three rows I want to display in the modal: Billing months for June 2016, May 2016, and April 2016, but only the latest(June 2016) will show. Here's the part of my code:
if(isset($_GET['id']))
{
$page_id = $_GET['id'];
$select_query = "SELECT * FROM billing_info INNER JOIN customer_login ON billing_info.account_no=customer_login.account_no WHERE billing_info.account_no='$page_id' ";
$run_query = mysqli_query($conn,$select_query);
while($row = mysqli_fetch_array($run_query))
{
$id = $row['user_id'];
$cust_fname = $row['cust_fname'];
$cust_mname = $row['cust_mname'];
$cust_lname = $row['cust_lname'];
$branch = $row['branch'];
$account_no = $row['account_no'];
$billing_month = $row['billing_month'];
$pres_reading = $row['pres_reading'];
$prev_reading = $row['prev_reading'];
$payment_status = $row['payment_status'];
$due_date = $row['due_date'];
$int_pres = intval($row["pres_reading"]);
$int_prev = intval($row["prev_reading"]);
$difference = $int_pres-$int_prev;
$payment = $difference*26.678;
$cust_fname = ucfirst($cust_fname);
$cust_mname = ucfirst($cust_mname);
$cust_lname = ucfirst($cust_lname);
$branch = ucfirst($branch);
?>
<div id="openModal" class="modalDialog" style="width:100%;">
<div id="form-sms" style="height: 500px; overflow: scroll;">
<div class="close"> X</div>
<form method="get" action="customer_view.php?id=<?php echo $id; ?>" name="id" enctype="multipart/form-data">
<table width="100%" bgcolor="white" align="center">
<style type="text/css">
td.hundred{
width: 80%;
text-align: center;
}
input {
width: 100%;
}
input[type="text"]{
width: 90%;
text-align: left;
}
input[type="submit"]{
width: 100%;
text-align: center;
}
textarea{
width: 90%;
text-align: left;
margin-left: 10%;
}
td {
padding: 10px;
}
.tdhover:hover {
color: #AFEEEE;
}
</style>
<tr >
<td align="center" colspan="10"><h1><?php echo $cust_fname." ".$cust_mname." ".$cust_lname." - ".$account_no." - ".$branch." Details" ?></h1></td>
</tr>
<tr bgcolor="#20B2AA">
<th>Billing Month</th>
<th>Present Reading</th>
<th>Previous Reading</th>
<th>Payment</th>
<th>Status</th>
<th>Due Date</th>
<th>Water Usage (in m<sup>3</sup>)</th>
<th>Edit</th>
</tr>
<tr bgcolor="#AFEEEE">
<td><?php echo $billing_month; ?></td>
<td><?php echo $pres_reading; ?></td>
<td><?php echo $prev_reading; ?></td>
<td><?php echo "Php " . $payment; ?></td>
<td><?php echo $payment_status; ?></td>
<td><?php echo $due_date; ?></td>
<td><?php echo $difference; ?></td>
<td>Edit</td>
</tr>
<tr style="margin-top: 10px;">
<td bgcolor="#20B2AA" align="center" class="tdhover" colspan="10">Add Billing Information</td>
</tr>
</table>
</form>
</style>
</table>
</form>
</div>
</div>
<?php } }?>
You should loop/parse the data only for <tr> and <td> Not for all tag like <table> and <div> outer the table. Html will loop all of inside { ... } sign.
Then, your style code should be placed the upper (not fix with html/php). This your code should be:
<style type="text/css">
td.hundred{
width: 80%;
text-align: center;
}
input {
width: 100%;
}
input[type="text"]{
width: 90%;
text-align: left;
}
input[type="submit"]{
width: 100%;
text-align: center;
}
textarea{
width: 90%;
text-align: left;
margin-left: 10%;
}
td {
padding: 10px;
}
.tdhover:hover {
color: #AFEEEE;
}
</style>
<?php
if (isset($_GET['id'])) {//open the isset
$page_id = $_GET['id'];
$select_query = "SELECT * FROM billing_info INNER JOIN customer_login ON billing_info.account_no=customer_login.account_no WHERE billing_info.account_no='$page_id' ";
$run_query = mysqli_query($conn, $select_query);
?>
<div id="openModal" class="modalDialog" style="width:100%;">
<div id="form-sms" style="height: 500px; overflow: scroll;">
<div class="close"> X</div>
<form method="get" action="customer_view.php?id=<?php echo $id; ?>" name="id" enctype="multipart/form-data">
<table width="100%" bgcolor="white" align="center">
<?php
while ($row = mysqli_fetch_array($run_query)) { //open the while
$id = $row['user_id'];
$cust_fname = $row['cust_fname'];
$cust_mname = $row['cust_mname'];
$cust_lname = $row['cust_lname'];
$branch = $row['branch'];
$account_no = $row['account_no'];
$billing_month = $row['billing_month'];
$pres_reading = $row['pres_reading'];
$prev_reading = $row['prev_reading'];
$payment_status = $row['payment_status'];
$due_date = $row['due_date'];
$int_pres = intval($row["pres_reading"]);
$int_prev = intval($row["prev_reading"]);
$difference = $int_pres - $int_prev;
$payment = $difference * 26.678;
$cust_fname = ucfirst($cust_fname);
$cust_mname = ucfirst($cust_mname);
$cust_lname = ucfirst($cust_lname);
$branch = ucfirst($branch);
?>
<tr >
<td align="center" colspan="10"><h1><?php echo $cust_fname . " " . $cust_mname . " " . $cust_lname . " - " . $account_no . " - " . $branch . " Details" ?></h1></td>
</tr>
<tr bgcolor="#20B2AA">
<th>Billing Month</th>
<th>Present Reading</th>
<th>Previous Reading</th>
<th>Payment</th>
<th>Status</th>
<th>Due Date</th>
<th>Water Usage (in m<sup>3</sup>)</th>
<th>Edit</th>
</tr>
<tr bgcolor="#AFEEEE">
<td><?php echo $billing_month; ?></td>
<td><?php echo $pres_reading; ?></td>
<td><?php echo $prev_reading; ?></td>
<td><?php echo "Php " . $payment; ?></td>
<td><?php echo $payment_status; ?></td>
<td><?php echo $due_date; ?></td>
<td><?php echo $difference; ?></td>
<td>Edit</td>
</tr>
<tr style="margin-top: 10px;">
<td bgcolor="#20B2AA" align="center" class="tdhover" colspan="10">Add Billing Information</td>
</tr>
<?php } //while closing
?>
</table>
</form>
</style>
</table>
</form>
</div>
</div>
Hopefully it will be success for you ;)

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>

Categories