...

View Full Version : How to store multiple totals using $_SESSIONS



user55
11-20-2007, 07:50 PM
Hi,

I have three PHP files:
=====================
totals.php
standings.php
totals_search.php

I am trying to pass sums/totals usings $_SESSIONS from totals.php to display in standings.php for each DIVISION. There are 12 DIVISIONS.

In totals.php, you can only view data and sums/totals for one DIVISION at a time. It has 12 DIVISION links at the top of the page for users to click and view the data for the DIVISION they wish to see.

This is an example of how the totals.php file looks like. (There is a lot more columns and rows) Each DIVISION has its own ID's, LOCATIONS, TOTALS, etc... The links look like this:

totals.php?search_fd1=1&&'> <-- DIVISION 1
totals.php?search_fd1=2&&'> <-- DIVISION 2
and so on...

I got those links by doing a search for each DIVISION on totals_search.php and just added the links in totals.php.

============================================================

http://i219.photobucket.com/albums/cc48/jdfw00/totals.gif

These are the Sessions that I am trying to pass on to standings.php:

$_SESSION["sum3"] = $sum3; // <-----this will show in standings.php
$_SESSION["sum4"] = $sum4; // <-----this will show in standings.php
$_SESSION["avgdsum"] = $avg4/$sum; // <-----this will show in standings.php
$_SESSION["scorestotal"] = $scorestotal; // <-----this will show in standings.php
=========================================================

This is what my standings.php file displays. The last four columns (QUOTA,MEMBERS,PERCENTAGE and SCORES) all show the same result for each DIVISION.

http://i219.photobucket.com/albums/cc48/jdfw00/wrong.gif

I have been told that the problem is that I am not keeping track of different sums/totals on a per record basis. So its overriding the values in the $_SESSION, thats why the last four columns in standings.php repeat.

I want to get it to look like this:

http://i219.photobucket.com/albums/cc48/jdfw00/correct.gif

user55
11-20-2007, 08:01 PM
I was trying to post all the code for totals.php, but there is a limit here of 20000 characters.

Here is some of it. There is more code that goes above it. This probably isn't enough. Please let me know. Any help is appreciated, SARA:



//...more code
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="totals.css">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>

<?php
if ($num_rows > 0) {
?>

<?php

if($result && mysql_num_rows($result) > 0)
{ for ($i = 0; $i < mysql_num_rows($result); $i++) {
$resultArray[$i] = mysql_fetch_array($result);

$color1 = "#ECECEC";
$color2 = "#ffffff";
$datarow_count = 0;
}

echo "<strong>DIVISION</strong> ";
echo ('<td><strong>'.$resultArray[0][1].'</strong></td>');
echo "<br />";
echo "Totals";
echo "<br />";
echo "<strong>MANAGER</strong> ";
echo ('<td><strong>'.$resultArray[0][118].'</strong></td>');
echo "<br />";
echo "As of "; print date("F j, Y");
echo "<br />";
echo "<br />";

echo "<strong>Choose a Division</strong>";
//Division Links
echo "<ul>
<li><a href='http://www.mysite.com/totals.php?search_fd1=1&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=2&&'>2</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=3&&'>3</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=4&&'>4</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=5&&'>5</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=6&&'>6</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=7&&'>7</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=8&&'>8</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=9&&'>9</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=10&&'>10</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=11&&'>11</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=12&&'>12</a>
</ul>";


echo "<table id=\"totals\" cellpadding=\'2\' cellspacing=\'0\'>";

echo "<tr>";
echo "<td>HR</td>";
echo "<td>PTO</td>";
echo "<td>ID</td>";
echo "<td>DIV</td>";
echo "<td>LOCATION</td>";
echo "<td>QUOTA</td>";
echo "<td>MEMB</td>";
echo "<td>% OF QUOTA</td>";
echo "<td>A</td>";
echo "<td>B</td>";
echo "<td>C</td>";
echo "<td>D</td>";
echo "<td>STOCKS</td>";
echo "<td>INSPECT</td>";
echo "<td>SERVICES</td>";
echo "<td>INS</td>";
echo "<td>MA</td>";
echo "<td>NH</td>";
echo "<td colspan=\"6\">GOALS</td>";
echo "<td>BALLOTS</td>";
echo "<td>VOTES</td>";
echo "<td>VACATION</td>";
echo "<td>ESSAYS</td>";
echo "<td>SALES</td>";
echo "<td colspan=\"3\">AWARDS</td>";
echo "<td>SEC</td>";
echo "<td>NOM</td>";
echo "<td colspan=\"2\">MTG</td>";
echo "</tr>";



$rowcount = 0;
$group1_current_row = 0;
$group2_current_row = 0;
$group3_current_row = 0;
$group4_current_row = 0;
$group5_current_row = 0;
$grouptotal_current_row = 0;
$isStart01 = 0;
$isStart02 = 0;
$isStart03 = 0;
$isStart04 = 0;
$isStart05 = 0;


foreach ($resultArray as $val) {
$datarow_color = ($datarow_count % 2) ? $color1 : $color2;

echo ('<tr bgcolor='. $datarow_color .'>');//first row
if (($rowcount%2) == 0) {
$css_class = "\"rows\"";
} else {
$css_class = "\"odd\"";
}
echo ('<td class=' . $css_class . ' align=default >'.($val[45] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.($val[47] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[0].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[1].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[2].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[4].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[6].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[7].'&nbsp</td>');

if ($val[9] == 'Y') $temp = 'X';
elseif ($val[9] == 'N') $temp = '';
else $temp = $val[9];

echo ('<td class=' . $css_class . ' align=default >'.$temp.'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[10] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[11] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[12] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[14] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[56] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[16] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[18].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[20] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[22] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[24].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[25].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[26].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[27].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[28].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[29].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[31].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[33].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[35].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[37].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[39] == 'Y' ? 'X' : '').'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[52].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[53].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[54].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[41].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[43].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[49].'&nbsp</td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[50].'&nbsp</td>');
echo ('</tr>');
$datarow_count++;
}

//begin totals
$empty1 = 0; $sum = 0; $sum3 = 0; $avg4 = 0; $empty5 = 0; $empty2 = 0; $empty3 = 0; $empty4 = 0;
foreach ($resultArray as $val) {
if(empty($val[45]) || $val[45] == 'N') $empty1++;
if(empty($val[47]) || $val[47] == 'N') $empty2++;
if(empty($val[0])) $empty3++;//id,division,location
if(empty($val[4])) $empty4++;//quota
if(empty($val[6])) $empty5++;//members
if(empty($val[9]) || $val[9] == 'N') $empty6++;
if(empty($val[10])) $empty7++;
if(empty($val[11])) $empty8++;
if(empty($val[12])) $empty9++;
if(empty($val[14])) $empty10++;
if(empty($val[56]) || $val[56] == 'N') $empty11++;
if(empty($val[16]) || $val[16] == 'N') $empty12++;
if(empty($val[20]) || $val[20] == 'N') $empty13++;
if(empty($val[22]) || $val[22] == 'N') $empty14++;
if(empty($val[24]) || $val[24] == 'N') $empty15++;
if(empty($val[25])) $empty16++;
if(empty($val[26])) $empty17++;
if(empty($val[27])) $empty18++;
if(empty($val[28])) $empty19++;
if(empty($val[29])) $empty20++;
if(empty($val[33])) $empty21++;
if(empty($val[35])) $empty22++;
if(empty($val[37])) $empty23++;
if(empty($val[39])) $empty24++;
if(empty($val[52])) $empty25++;
if(empty($val[53])) $empty26++;
if(empty($val[54])) $empty27++;
if(empty($val[41])) $empty28++;
if(empty($val[43])) $empty29++;
if(empty($val[49])) $empty30++;
if(empty($val[50])) $empty31++;
$sum++;
$sum3 += $val[4];//total quota
$sum4 += $val[6];//total members
$sum5 += $val[18];
$sum6 += $val[31];
$avg4 += $val[7];//average percentage
}

//begin division report totals
echo "<tr class=\"divisiontotals\">
<td>".($empty1 == 0 ? 'X' : '')."</td>
<td>".($empty2 == 0 ? 'X' : '')."</td>
<td colspan=\"3\">DIVISION REPORTS</td>
<td></td>
<td></td>
<td></td>
<td>".($empty6 == 0 ? 'X' : '')."</td>
<td>".($empty7 == 0 ? 'X' : '')."</td>
<td>".($empty8 == 0 ? 'X' : '')."</td>
<td>".($empty9 == 0 ? 'X' : '')."</td>
<td>".($empty10 == 0 ? 'X' : '')."</td>
<td>".($empty11 == 0 ? 'X' : '')."</td>
<td>".($empty12 == 0 ? 'X' : '')."</td>
<td></td>
<td>".($empty13 == 0 ? 'X' : '')."</td>
<td>".($empty14 == 0 ? 'X' : '')."</td>
<td>".($empty15 == 0 ? 'X' : '')."</td>
<td>".($empty16 == 0 ? 'X' : '')."</td>
<td>".($empty17 == 0 ? 'X' : '')."</td>
<td>".($empty18 == 0 ? 'X' : '')."</td>
<td>".($empty19 == 0 ? 'X' : '')."</td>
<td>".($empty20 == 0 ? 'X' : '')."</td>
<td></td>
<td>".($empty21 == 0 ? 'X' : '')."</td>
<td>".($empty22 == 0 ? 'X' : '')."</td>
<td>".($empty23 == 0 ? 'X' : '')."</td>
<td align=center>".($empty24 == 0 ? 'X' : '')."</td>
<td>".($empty25 == 0 ? 'X' : '')."</td>
<td>".($empty26 == 0 ? 'X' : '')."</td>
<td>".($empty27 == 0 ? 'X' : '')."</td>
<td>".($empty28 == 0 ? 'X' : '')."</td>
<td>".($empty29 == 0 ? 'X' : '')."</td>
<td>".($empty30 == 0 ? 'X' : '')."</td>
<td>".($empty31 == 0 ? 'X' : '')."</td>
</tr>";
//end division report totals

echo "<tr class=\"trtotals\">
<td>".($sum-$empty1)."</td>
<td>".($sum-$empty2)."</td>
<td colspan=\"3\">".($sum-$empty3)." Total</td>
<td>$sum3</td>
<td>$sum4</td>
<td>".number_format($avg4/$sum, 2)."%</td>
<td>".($sum-$empty6)."</td>
<td>".($sum-$empty7)."</td>
<td>".($sum-$empty8)."</td>
<td>".($sum-$empty9)."</td>
<td>".($sum-$empty10)."</td>
<td>".($sum-$empty11)."</td>
<td>".($sum-$empty12)."</td>
<td>$sum5</td>
<td>".($sum-$empty13)."</td>
<td>".($sum-$empty14)."</td>
<td>".($sum-$empty15)."</td>
<td>".($sum-$empty16)."</td>
<td>".($sum-$empty17)."</td>
<td>".($sum-$empty18)."</td>
<td>".($sum-$empty19)."</td>
<td>".($sum-$empty20)."</td>
<td>$sum6</td>
<td>".($sum-$empty21)."</td>
<td>".($sum-$empty22)."</td>
<td>".($sum-$empty23)."</td>
<td>".($sum-$empty24)."</td>
<td>".($sum-$empty25)."</td>
<td>".($sum-$empty26)."</td>
<td>".($sum-$empty27)."</td>
<td>".($sum-$empty28)."</td>
<td>".($sum-$empty29)."</td>
<td>".($sum-$empty30)."</td>
<td>".($sum-$empty31)."</td>
</tr>";


echo "<tr class=\"trpoints1\">";//1st row of scores
echo ('<td>'.($sum-$empty1).'</td>');
echo ('<td>'.($sum-$empty2).'</td>');
echo "<td colspan=\"3\">Scores</td>";
echo ('<td>'.number_format($resultArray[0][61]/$sum3 * $sum4, 2).'</td>');
echo "<td colspan=\"2\"></td>";
echo "<td colspan=\"4\">".number_format(8 / (4*$sum-$empty3) * $sum-$empty6, 2)."</td>";
echo "<td colspan=\"3\">".number_format((3 / $sum-$empty3) * $sum-$empty10, 2)."</td>";
echo "<td>".number_format(9 / (20*$sum-$empty3), 2)."</td>";
echo "<td>".number_format((3/$sum-$empty3) * ($sum-$empty13), 2)."</td>";
echo "<td>".number_format((3/$sum-$empty3) * ($sum-$empty14), 2)."</td>";
echo "<td colspan=\"6\">".number_format(3/(6*$sum-$empty3) * ($sum-$empty15+$sum-$empty16+$sum-$empty17+$sum-$empty18+$sum-$empty19+$sum-$empty20), 2)."</td>";
echo "<td>".number_format(3/ (9*$sum-$empty3) * ($sum-$empty14), 2)."</td>";
echo ('</tr>');


$scorestotal = ($sum-$empty1)+($sum-$empty2)+($resultArray[0][61]/$sum3 * $sum4)+(8 / (4*$sum-$empty3) * $sum-$empty6)+((3 / $sum-$empty3) * $sum-$empty10)+(9 / (20*$sum-$empty3))+
((3/$sum-$empty3) * ($sum-$empty13))+((3/$sum-$empty3) * ($sum-$empty14))+(3/(6*$sum-$empty3) * ($sum-$empty15+$sum-$empty16+$sum-$empty17+$sum-$empty18+$sum-$empty19+$sum-$empty20))+(3/ (9*$sum-$empty3) * ($sum-$empty14));


$_SESSION["sum3"] = $sum3; // <-----this will show in standings.php
$_SESSION["sum4"] = $sum4; // <-----this will show in standings.php
$_SESSION["avgdsum"] = $avg4/$sum; // <-----this will show in standings.php
$_SESSION["scorestotal"] = $scorestotal; // <-----this will show in standings.php


//echo ('<tr>');//2nd row of scores
echo "<tr class=\"trpoints\">";
echo ('<td>'.$resultArray[0][58].'</td>');
echo ('<td>'.$resultArray[0][59].'</td>');
echo "<td colspan=\"3\"></td>";
echo ('<td>'.$resultArray[0][60].'</td>');
echo ('<td>'.$resultArray[0][61].'</td>');
echo ('<td>'.$resultArray[0][62].'</td>');
echo ('<td>'.$resultArray[0][63].'</td>');
echo ('<td>'.$resultArray[0][64].'</td>');
echo ('<td>'.$resultArray[0][65].'</td>');
echo ('<td>'.$resultArray[0][66].'</td>');
echo ('<td>'.$resultArray[0][67].'</td>');
echo ('<td>'.$resultArray[0][68].'</td>');
echo ('<td>'.$resultArray[0][69].'</td>');
echo ('<td>'.$resultArray[0][70].'</td>');
echo ('<td>'.$resultArray[0][71].'</td>');
echo ('<td>'.$resultArray[0][72].'</td>');
echo ('<td>'.$resultArray[0][73].'</td>');
echo ('<td>'.$resultArray[0][74].'</td>');
echo ('<td>'.$resultArray[0][75].'</td>');
echo ('<td>'.$resultArray[0][98].'</td>');
echo ('<td>'.$resultArray[0][99].'</td>');
echo ('<td>'.$resultArray[0][100].'</td>');
echo ('<td>'.$resultArray[0][101].'</td>');
echo ('<td>'.$resultArray[0][102].'</td>');
echo ('<td>'.$resultArray[0][76].'</td>');
echo ('<td>'.$resultArray[0][77].'</td>');
echo ('<td>'.$resultArray[0][98].'</td>');
echo ('<td>'.$resultArray[0][99].'</td>');
echo ('</tr>');
echo "</table>";

//session_write_close();

echo "<br />";

//begin bottom totals $$$
$total = $resultArray[0][1] + $resultArray[0][2] + $resultArray[0][3];

echo "<div id=\"boxleft\">";//begin left column
echo "<dl>";
echo "<dt>FIRST</dt>";
echo ('<dd>'.$resultArray[0][78].'</dd>');
echo "<dt>MISC</dt>";
echo ('<dd>'.$resultArray[0][79].'</dd>');
echo "<dt>FINAL</dt>";
echo ('<dd>'.$resultArray[0][80].'</dd>');
echo "<dt></dt>";
$resultArray[0][81]=$resultArray[0][78]+$resultArray[0][79]+$resultArray[0][80];
echo ('<dd>'.$resultArray[0][81].'</dd>');

echo "<dt>NEW TOTAL</dt>";

echo '<dd>'.round($resultArray[0][81] / ($sum3/100), 2).'%</dd>';
echo "<dd></dd>
</dl>";

echo "<div class=\"clear\"></div>
</div>";//end left column


echo "<div id=\"otherbox\">";
echo "<table id=\"scorestable\" cellspacing=\"0\">";
echo "<tr>
<th scope=\"col\" abbr=\"Type\" class=\"nobg\"></th>
<th scope=\"col\" abbr=\"Col-1\">1st</th>
<th scope=\"col\" abbr=\"Col-2\">2nd</th>
</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A1</th>";
echo ('<td>'.$resultArray[0][83].'</td>');
echo ('<td>'.$resultArray[0][103].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"two\">A2</th>";
echo ('<td>'.$resultArray[0][84].'</td>');
echo ('<td>'.$resultArray[0][104].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A3</th>";
echo ('<td>'.$resultArray[0][85].'</td>');
echo ('<td>'.$resultArray[0][105].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"two\">A4</th>";
echo ('<td>'.$resultArray[0][86].'</td>');
echo ('<td>'.$resultArray[0][106].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A5</th>";
echo ('<td>'.$resultArray[0][87].'</td>');
echo ('<td>'.$resultArray[0][107].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"two\">A6</th>";
echo ('<td>'.$resultArray[0][88].'</td>');
echo ('<td>'.$resultArray[0][108].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A7</th>";
echo ('<td>'.$resultArray[0][89].'</td>');
echo ('<td>'.$resultArray[0][109].'</td>');
echo "</tr>";

echo "</table>
</div>";//end 1st scores table

echo "<div id=\"box2\">";
echo "<table id=\"scorestable\" cellspacing=\"0\">";
echo "<tr>
<th scope=\"col\" abbr=\"Type\" class=\"nobg\"></th>
<th scope=\"col\" abbr=\"Col-1\">1st</th>
<th scope=\"col\" abbr=\"Col-2\">2nd</th>
</tr>";
echo "<tr>
<th scope=\"row\" class=\"alt\">A8</th>";
echo ('<td>'.$resultArray[0][90].'</td>');
echo ('<td>'.$resultArray[0][110].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A9</th>";
echo ('<td>'.$resultArray[0][91].'</td>');
echo ('<td>'.$resultArray[0][111].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"alt\">A10</th>";
echo ('<td>'.$resultArray[0][92].'</td>');
echo ('<td>'.$resultArray[0][112].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"one\">A11</th>";
echo ('<td>'.$resultArray[0][93].'</td>');
echo ('<td>'.$resultArray[0][113].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"spec\">Total Extra Scores</th>";
//begin TOTAL EXTRA SCORES - Col-1
$resultArray[0][94]=$resultArray[0][83]+$resultArray[0][84]+$resultArray[0][85]+$resultArray[0][86]+$resultArray[0][87]+$resultArray[0][88]+$resultArray[0][89]+$resultArray[0][90]+$resultArray[0][91]+$resultArray[0][92]+$resultArray[0][93];
echo ('<td>'.$resultArray[0][94].'</td>');
//begin TOTAL EXTRA SCORES - Col-2
$resultArray[0][114]=$resultArray[0][103]+$resultArray[0][104]+$resultArray[0][105]+$resultArray[0][106]+$resultArray[0][107]+$resultArray[0][108]+$resultArray[0][109]+$resultArray[0][110]+$resultArray[0][111]+$resultArray[0][112]+$resultArray[0][113];
echo ('<td>'.$resultArray[0][114].'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"spec2\">Total Scores from Above</th>";
//begin TOTAL SCORES FROM ABOVE - Col-1
$resultArray[0][95]=$resultArray[0][58]+$resultArray[0][59]+$resultArray[0][60]+$resultArray[0][61]+$resultArray[0][62]+$resultArray[0][63]+$resultArray[0][64]+$resultArray[0][65]+$resultArray[0][66]+$resultArray[0][67]+$resultArray[0][68]+$resultArray[0][69]+$resultArray[0][70]+$resultArray[0][71]+$resultArray[0][72]+$resultArray[0][73]+$resultArray[0][74]+$resultArray[0][75]+$resultArray[0][76]+$resultArray[0][77];
echo ('<td>'.$resultArray[0][95].'</td>');
echo ('<td>'.number_format($pointstotal, 2).'</td>');
echo "</tr>";
echo "<tr>
<th scope=\"row\" class=\"spec\">Total Scores</th>";
//begin TOTAL SCORES - Col-1
$resultArray[0][96]=$resultArray[0][94]+$resultArray[0][95];
echo ('<td>'.$resultArray[0][96].'</td>');
$resultArray[0][116]=$resultArray[0][114]+$pointstotal;
echo ('<td>'.number_format($resultArray[0][116], 2).'</td>');
echo "</tr>";

echo "</table>

</div>";//end 2nd scores table
echo "<br />";
echo "<div id=\"bottom-message\">";
echo "<p><strong>NOTES:</strong> ";
echo (''.$resultArray[0][97].'');
echo "</p>";
echo "<div>";

} // end if results

?>


<?php
}
else{
if ($filter_string != ""){
?>
<Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
<tr>
<td height="80" align="Default" bgcolor="#FFFFFF">

<font color="#000099" size="2">
No record matched your search criteria.
</font>
</td>
</tr>
</Table><br>

<?php
}else{
?><Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
<tr>
<td height="80" align="Default" bgcolor="#FFFFFF">
<font color="#000099" size="2">
No record found.
</font>
</td>
</tr>
</Table><br>

<?php
}
}
?>

<?php
if ($result > 0) {mysql_free_result($result);}
if ($grandtotal_result > 0) {mysql_free_result($grandtotal_result);}
@mysql_close($link);
?>

</center>

</body>
</html>

user55
11-20-2007, 08:32 PM
Maybe,

This might not be possible since I cannot post all the code because of the limit.

aedrin
11-20-2007, 08:39 PM
That might mean you need to optimize some of your code. That looks awfully repetitive.

Fumigator
11-20-2007, 09:11 PM
Are you not familiar with loops? For example, this code:


echo ('<td>'.$resultArray[0][60].'</td>');
echo ('<td>'.$resultArray[0][61].'</td>');
echo ('<td>'.$resultArray[0][62].'</td>');
echo ('<td>'.$resultArray[0][63].'</td>');
echo ('<td>'.$resultArray[0][64].'</td>');
echo ('<td>'.$resultArray[0][65].'</td>');
echo ('<td>'.$resultArray[0][66].'</td>');
echo ('<td>'.$resultArray[0][67].'</td>');
echo ('<td>'.$resultArray[0][68].'</td>');
echo ('<td>'.$resultArray[0][69].'</td>');
echo ('<td>'.$resultArray[0][70].'</td>');
echo ('<td>'.$resultArray[0][71].'</td>');
echo ('<td>'.$resultArray[0][72].'</td>');
echo ('<td>'.$resultArray[0][73].'</td>');
echo ('<td>'.$resultArray[0][74].'</td>');
echo ('<td>'.$resultArray[0][75].'</td>');
echo ('<td>'.$resultArray[0][98].'</td>');
echo ('<td>'.$resultArray[0][99].'</td>');
echo ('<td>'.$resultArray[0][100].'</td>');
echo ('<td>'.$resultArray[0][101].'</td>');
echo ('<td>'.$resultArray[0][102].'</td>');
echo ('<td>'.$resultArray[0][76].'</td>');
echo ('<td>'.$resultArray[0][77].'</td>');
echo ('<td>'.$resultArray[0][98].'</td>');
echo ('<td>'.$resultArray[0][99].'</td>');


Should be written like this:


for ($i = 60; $i < 100; $i++) {
echo "<td>{$resultArray[0][$i]}</td>";
}


All of those $empty15, $empty16 etc variables should be one array with looping constructs. Fix your code to use arrays and loops and that will make your original objective much easier.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum