update multi row php - 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?

Related

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>

display all records of database table in div in php

here it showing all records from database but it shows all empty div first then below it shows all records .i want to show each record to be shown in single div in rows.
<div id="winnercontainer">
<h2 style="background-color:#9966FF; width:850px; height:30px; font:bold; font- size:22px; color:#FFFFFF; padding-left:20px;">Winners</h2>
<?php
include('pagination/ps_pagination.php');
$conn = mysql_connect('localhost','root','');
if(!$conn) die("Failed to connect to database!");
$status = mysql_select_db('gunjanbid', $conn);
if(!$status) die("Failed to select database!");
$sql = 'SELECT * FROM winners';
$pager = new PS_Pagination($conn, $sql,10, 10);
//The paginate() function returns a mysql result set for the current page
$rs = $pager->paginate();
?>
<table>
<?php
while($row=mysql_fetch_array($rs)){
?>
<div id="winner">
<tr>
<td ><img src="memberpic/myphoto.jpg" width="150" height="150" alt="001" /></td>
<td > </td>
<td ><table >
<tr>
<td >Auction Item : <?php echo $row['Items']; ?></td>
</tr>
<tr>
<td>Rs. <?php echo $row['Rs']; ?></td>
</tr>
<tr>
<td>Winning Bid Value : Rs. <?php echo $row['WinningBidValue']; ?></td>
</tr>
<tr>
<td>MRP : Rs. <?php echo $row['MRP']; ?></td>
</tr>
<tr>
<td>Auction closed on : <?php echo $row['enddate']; ?></td>
</tr>
<tr>
<td>Winner : <?php echo $row['Winner']; ?></td>
</tr>
<tr>
<td>City: <?php echo $row['City']; ?></td>
</tr>
<tr>
<td >Delivery Status: <?php echo $row['DeliveryStatus']; ?></td>
</tr>
</table></td>
<td > </td>
<td id=save><font color=black>SAVED:</font> Rs.<?php echo $row['MRP']- $row['WinningBidValue']; ?></td>
<td > </td>
<td ><img src=productimage/1/1.1.jpg width="200" height="193" alt="001" /></td>
</tr>
</div>
<?php
}
?>
</table>
<?php
//Display the navigation
//echo $pager->renderFullNav();
echo '<div style="text-align:center">'.$pager->renderFullNav().'</div>';
?>
</div>
abd my stylesheet s are
#winnercontainer
{
width:870px;
height:auto;
background-color:#CCCCCC;
border:solid #9966FF;
border-radius:10px;
margin:auto;
clear:both;
margin:10px;
position:relative;
}
#winner
{
width:840px;
height:250px;
background-color: #999999;
border: solid #9966FF;
border-radius:10px;
margin:auto;
clear:both;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 15px;
position:relative;
}
i want all my records to be place in div means each div have one record to be display.plz help me ,i am new here.
I'll give you a start with some old code I have that reads a table from a MySQL database and prints it out on a screen. You can modify it as you see fit. It's a php file that resides on the server.
<?php
echo "<head><title>Read list</title></head>";
$host = "xxxxxxxxxxx";
$user = "xxxxxxxxxxx";
$password = "xxxxxxxxxxx";
$dbname = "xxxxxxxxxxx";
$cxn = mysqli_connect($host,$user,$password,$dbname);
if (mysqli_connect_errno()) {echo "No connection" . mysqli_connect_error();}
$query = " select * from list where uniqueid >= 0 ";
$result = mysqli_query($cxn, $query) or die ("could not query database");
echo "<table cellpadding=1px border=1>";
while ($row = mysqli_fetch_array($result))
{
$uniqueid = $row['uniqueid'];
$localid = $row['localid'];
$mdid = $row['mid'];
$type = $row['type'];
echo "<tr><td>".$uniqueid."</td><td>".$localid."</td><td>".$mdd."</td><td>".$type."</td></tr>";
}
echo "</table>";
?>

PHP get database data into HTML table

I want to put my database data into HTML table and its not so easy as it seems, Look at my photographs and code to get better understanding on what my problem is
My Result:
Desired Result:
Basically i want to separate the results as the red line indicates so each item becomes seperate.
PHP code:
$sql = mysql_query("SELECT * FROM products"); ?>
<table id='display'>
<?php
while($rows = mysql_fetch_array($sql))
{
?>
<tr><td><?php echo "<img src=$rows[$product_image] height='200px' width='200px'>" ?></td></tr>
<tr>
<td><b><?php echo "$rows[$product_name]" ?></td>
<td><b><?php echo "Avalible: $rows[$product_qua]" ?></td>
<td><b><?php echo "Price: £ $rows[$product_price]" ?></td>
<td><b><?php echo "Description: $rows[$product_des]" ?></td>
</tr>
<tr>
<td><strong><p>Please Login To purchase this item </p></strong>Login</td>
</tr>
<?php
}
?>
</table>
CSS code:
table#display{
float:left;
border: 5px solid black;
margin-top:50px;
margin-left:10px;
}
table#display td{
border: 1px solid black;
padding:0 8px;
}
table#display tr{
border: 1px solid black;
padding:0 8px;
}
My solution:
PHP Code:
$sql = mysql_query("SELECT * FROM products"); ?>
<?php
while($rows = mysql_fetch_array($sql))
{
?>
<table class='display'>
<tr><td><?php echo "<img src=$rows[$product_image] height='200px' width='200px'>" ?></td></tr>
<tr>
<td><b><?php echo "$rows[$product_name]" ?></td>
<td><b><?php echo "Avalible: $rows[$product_qua]" ?></td>
<td><b><?php echo "Price: £ $rows[$product_price]" ?></td>
<td><b><?php echo "Description: $rows[$product_des]" ?></td>
</tr>
<tr>
<td><strong><p>Please Login To purchase this item </p></strong>Login</td>
</tr>
</table>
<?php
}
?>
The CSS:
table.display{
float:left;
border: 5px solid black;
margin-top:50px;
margin-left:10px;
margin-bottom: 10px;
}

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