fcruz5
asked on
How do I display my data like this in PHP?
Hi,
I have three PHP files:
=====================
totals.php <-- this is the file where I get sessions and totals to pass on to standings.php
standings.php <-- this is the file that I am having trouble with
totals_search.php <-- this file is used to do a search for a DIVISION to view its data.
I would like my standings.php file to display data like the following:
ORDER | DIVISION | MGR | QUOTA | MEMBERS | PERCENTAGE | SCORES
========================== ========== ========== ========== =========
01 01 JOHN 1250 4411 23.9% 19.75
02 02 BOB 2150 1566 42.2% 22.96
03 03 TOM 1100 2697 12.9% 19.22
04 04 FRED 1500 2120 65.5% 95.11
05 05 SAM 1200 1014 11.2% 54.10
06 06 ROY 1210 3519 19.1% 61.87
07 07 GUY 4290 1422 42.3% 88.56
08 08 AMY 1340 1891 66.8% 23.43
09 09 JOEY 1110 4032 97.7% 24.04
10 10 DON 3600 4411 91.5% 57.21
11 11 ALICE 1592 4411 39.9% 71.07
12 12 WILLY 2897 4411 56.4% 68.94
But instead, it will displays like this: The last four columns (QUOTA,MEMBERS,PERCENTAGE and SCORES) all show the same result for each DIVISION. I have been told thats its because the session variables are only being passed down once from totals.php. But I don't know of any other way to do this.
The data that I am passing is not stored in the database, they are just sum totals.
What can I do to fix this?
ORDER | DIVISION | MGR | QUOTA | MEMBERS | PERCENTAGE | SCORES
========================== ========== ========== ========== =========
01 01 JOHN 1250 4411 23.9% 19.75
02 02 BOB 1250 4411 23.9% 19.75
03 03 TOM 1250 4411 23.9% 19.75
04 04 FRED 1250 4411 23.9% 19.75
05 05 SAM 1250 4411 23.9% 19.75
06 06 ROY 1250 4411 23.9% 19.75
07 07 GUY 1250 4411 23.9% 19.75
08 08 AMY 1250 4411 23.9% 19.75
09 09 JOEY 1250 4411 23.9% 19.75
10 10 DON 1250 4411 23.9% 19.75
11 11 ALICE 1250 4411 23.9% 19.75
12 12 WILLY 1250 4411 23.9% 19.75
The following is the code for totals.php:
I have three PHP files:
=====================
totals.php <-- this is the file where I get sessions and totals to pass on to standings.php
standings.php <-- this is the file that I am having trouble with
totals_search.php <-- this file is used to do a search for a DIVISION to view its data.
I would like my standings.php file to display data like the following:
ORDER | DIVISION | MGR | QUOTA | MEMBERS | PERCENTAGE | SCORES
==========================
01 01 JOHN 1250 4411 23.9% 19.75
02 02 BOB 2150 1566 42.2% 22.96
03 03 TOM 1100 2697 12.9% 19.22
04 04 FRED 1500 2120 65.5% 95.11
05 05 SAM 1200 1014 11.2% 54.10
06 06 ROY 1210 3519 19.1% 61.87
07 07 GUY 4290 1422 42.3% 88.56
08 08 AMY 1340 1891 66.8% 23.43
09 09 JOEY 1110 4032 97.7% 24.04
10 10 DON 3600 4411 91.5% 57.21
11 11 ALICE 1592 4411 39.9% 71.07
12 12 WILLY 2897 4411 56.4% 68.94
But instead, it will displays like this: The last four columns (QUOTA,MEMBERS,PERCENTAGE and SCORES) all show the same result for each DIVISION. I have been told thats its because the session variables are only being passed down once from totals.php. But I don't know of any other way to do this.
The data that I am passing is not stored in the database, they are just sum totals.
What can I do to fix this?
ORDER | DIVISION | MGR | QUOTA | MEMBERS | PERCENTAGE | SCORES
==========================
01 01 JOHN 1250 4411 23.9% 19.75
02 02 BOB 1250 4411 23.9% 19.75
03 03 TOM 1250 4411 23.9% 19.75
04 04 FRED 1250 4411 23.9% 19.75
05 05 SAM 1250 4411 23.9% 19.75
06 06 ROY 1250 4411 23.9% 19.75
07 07 GUY 1250 4411 23.9% 19.75
08 08 AMY 1250 4411 23.9% 19.75
09 09 JOEY 1250 4411 23.9% 19.75
10 10 DON 1250 4411 23.9% 19.75
11 11 ALICE 1250 4411 23.9% 19.75
12 12 WILLY 1250 4411 23.9% 19.75
The following is the code for totals.php:
<?php
require('conn.php');
$err_string="";
$quotechar = "`";
$quotedate = "'";
$sql = "";
$sql_ext = "";
$cellvalue = "";
$istrdata = "";
$sortstring = "";
$fields = array();
$fields[0] = "master.`id`";
$fields[1] = "master.`division`";
$fields[2] = "master.`location`";
$fields[3] = "quota.`id`";
$fields[4] = "quota.`quota`";
$fields[5] = "members.`id`";
$fields[6] = "members.`total`";
$fields[7] = "members.`percentage`";
$fields[8] = "bond.`id`";
$fields[9] = "bond.`a`";
$fields[10] = "bond.`b`";
$fields[11] = "bond.`c`";
$fields[12] = "bond.`d`";
$fields[13] = "stocks.`id`";
$fields[14] = "stocks.`stocks`";
$fields[15] = "services.`id`";
$fields[16] = "services.`services`";
$fields[17] = "ins.`id`";
$fields[18] = "ins.`reports`";
$fields[19] = "ma.`id`";
$fields[20] = "ma.`ma`";
$fields[21] = "nh.`id`";
$fields[22] = "nh.`donations`";
$fields[23] = "goals.`id`";
$fields[24] = "goals.`a`";
$fields[25] = "goals.`b`";
$fields[26] = "goals.`c`";
$fields[27] = "goals.`d`";
$fields[28] = "goals.`e`";
$fields[29] = "goals.`f`";
$fields[30] = "ballots.`id`";
$fields[31] = "ballots.`registered`";
$fields[32] = "votes.`id`";
$fields[33] = "votes.`elections`";
$fields[34] = "vacation.`id`";
$fields[35] = "vacation.`used`";
$fields[36] = "essays.`id`";
$fields[37] = "essays.`checked`";
$fields[38] = "sales.`id`";
$fields[39] = "sales.`goal`";
$fields[40] = "sec.`id`";
$fields[41] = "sec.`registered`";
$fields[42] = "nom.`id`";
$fields[43] = "nom.`available`";
$fields[44] = "hr.`id`";
$fields[45] = "hr.`payroll`";
$fields[46] = "pto.`id`";
$fields[47] = "pto.`used`";
$fields[48] = "mtg.`id`";
$fields[49] = "mtg.`week`";
$fields[50] = "mtg.`month`";
$fields[51] = "awards.`id`";
$fields[52] = "awards.`a`";
$fields[53] = "awards.`b`";
$fields[54] = "awards.`c`";
$fields[55] = "inspect.`id`";
$fields[56] = "inspect.`failed`";
$fields[57] = "scores.`division`";
$fields[58] = "scores.`a1`";
$fields[59] = "scores.`a2`";
$fields[60] = "scores.`a3`";
$fields[61] = "scores.`a4`";
$fields[62] = "scores.`a5`";
$fields[63] = "scores.`a6`";
$fields[64] = "scores.`a7`";
$fields[65] = "scores.`a8`";
$fields[66] = "scores.`a9`";
$fields[67] = "scores.`a10`";
$fields[68] = "scores.`a11`";
$fields[69] = "scores.`a12`";
$fields[70] = "scores.`a13`";
$fields[71] = "scores.`a14`";
$fields[72] = "scores.`a15`";
$fields[73] = "scores.`a16`";
$fields[74] = "scores.`a17`";
$fields[75] = "scores.`a18`";
$fields[76] = "scores.`a19`";
$fields[77] = "scores.`a20`";
$fields[78] = "scores.`a21`";
$fields[79] = "scores.`a22`";
$fields[80] = "scores.`a23`";
$fields[81] = "scores.`a24`";
$fields[82] = "scores.`a25`";
$fields[83] = "scores.`a26`";
$fields[84] = "scores.`a27`";
$fields[85] = "scores.`a28`";
$fields[86] = "scores.`a29`";
$fields[87] = "scores.`a30`";
$fields[88] = "scores.`a31`";
$fields[89] = "scores.`a32`";
$fields[90] = "scores.`a33`";
$fields[91] = "scores.`a34`";
$fields[92] = "scores.`a35`";
$fields[93] = "scores.`a36`";
$fields[94] = "scores.`totalextrascores`";
$fields[95] = "scores.`totalscoresabove`";
$fields[96] = "scores.`totalscore`";
$fields[97] = "scores.`notes`";
$fields[98] = "scores.`a37`";
$fields[99] = "scores.`a38`";
$fields[100] = "scores.`a39`";
$fields[101] = "scores.`a40`";
$fields[102] = "scores.`a41`";
$fields[103] = "scores.a42";
$fields[104] = "scores.a43";
$fields[105] = "scores.a44";
$fields[106] = "scores.a45";
$fields[107] = "scores.a46";
$fields[108] = "scores.a47";
$fields[109] = "scores.a48";
$fields[110] = "scores.a49";
$fields[111] = "scores.a50";
$fields[112] = "scores.a51";
$fields[113] = "scores.a52";
$fields[114] = "scores.a53";
$fields[115] = "scores.a54";
$fields[116] = "scores.a55";
$fields[117] = "managers.`division`";
$fields[118] = "managers.`name`";
$sql .= " Select";
$sql .= " master.`id`,";
$sql .= " master.`division`,";
$sql .= " master.`city`,";
$sql .= " quota.`id`,";
$sql .= " quota.`quota`,";
$sql .= " members.`id`,";
$sql .= " members.`total`,";
$sql .= " members.`percentage`,";
$sql .= " bond.`id`,";
$sql .= " bond.`jun`,";
$sql .= " bond.`sep`,";
$sql .= " bond.`dec`,";
$sql .= " bond.`mar`,";
$sql .= " stocks.`id`,";
$sql .= " stocks.`stocks`,";
$sql .= " services.`id`,";
$sql .= " services.`services`,";
$sql .= " ins.`id`,";
$sql .= " ins.`reports`,";
$sql .= " ma.`id`,";
$sql .= " ma.`ma`,";
$sql .= " nh.`id`,";
$sql .= " nh.`donations`,";
$sql .= " goals.`id`,";
$sql .= " goals.`a`,";
$sql .= " goals.`b`,";
$sql .= " goals.`c`,";
$sql .= " goals.`d`,";
$sql .= " goals.`e`,";
$sql .= " goals.`f`,";
$sql .= " ballots.`id`,";
$sql .= " ballots.`registered`,";
$sql .= " votes.`id`,";
$sql .= " votes.`elections`,";
$sql .= " vacation.`id`,";
$sql .= " vacation.`used`,";
$sql .= " essays.`id`,";
$sql .= " essays.`checked`,";
$sql .= " sales.`id`,";
$sql .= " sales.`goal`,";
$sql .= " sec.`id`,";
$sql .= " sec.`registered`,";
$sql .= " nom.`id`,";
$sql .= " nom.`available`,";
$sql .= " hr.`id`,";
$sql .= " hr.`payroll`,";
$sql .= " pto.`id`,";
$sql .= " pto.`used`,";
$sql .= " mtg.`id`,";
$sql .= " mtg.`week`,";
$sql .= " mtg.`month`,";
$sql .= " awards.`id`,\n";
$sql .= " awards.`a`,\n";
$sql .= " awards.`b`,\n";
$sql .= " awards.`c`,\n";
$sql .= " inspect.`id`,";
$sql .= " inspect.`failed`,";
$sql .= " scores.`division`,";
$sql .= " scores.`a1`,\n";
$sql .= " scores.`a2`,\n";
$sql .= " scores.`a3`,\n";
$sql .= " scores.`a4`,\n";
$sql .= " scores.`a5`,\n";
$sql .= " scores.`a6`,\n";
$sql .= " scores.`a7`,\n";
$sql .= " scores.`a8`,\n";
$sql .= " scores.`a9`,\n";
$sql .= " scores.`a10`,\n";
$sql .= " scores.`a11`,\n";
$sql .= " scores.`a12`,\n";
$sql .= " scores.`a13`,\n";
$sql .= " scores.`a14`,\n";
$sql .= " scores.`a15`,\n";
$sql .= " scores.`a16`,\n";
$sql .= " scores.`a17`,\n";
$sql .= " scores.`a18`,\n";
$sql .= " scores.`a19`,\n";
$sql .= " scores.`a20`,\n";
$sql .= " scores.`a21`,\n";
$sql .= " scores.`a22`,\n";
$sql .= " scores.`a23`,\n";
$sql .= " scores.`a24`,\n";
$sql .= " scores.`a25`,\n";
$sql .= " scores.`a26`,\n";
$sql .= " scores.`a27`,\n";
$sql .= " scores.`a28`,\n";
$sql .= " scores.`a29`,\n";
$sql .= " scores.`a30`,\n";
$sql .= " scores.`a31`,\n";
$sql .= " scores.`a32`,\n";
$sql .= " scores.`a33`,\n";
$sql .= " scores.`a34`,\n";
$sql .= " scores.`a35`,\n";
$sql .= " scores.`a36`,\n";
$sql .= " scores.`totalextrascores`,\n";
$sql .= " scores.`totalscoressabove`,\n";
$sql .= " scores.`totalscore`,\n";
$sql .= " scores.`notes`,\n";
$sql .= " scores.`a37`,\n";
$sql .= " scores.`a38`,\n";
$sql .= " scores.`a39`,\n";
$sql .= " scores.`a40`,\n";
$sql .= " scores.`a41`,\n";
$sql .= " scores.`a42`,\n";
$sql .= " scores.`a43`,\n";
$sql .= " scores.`a44`,\n";
$sql .= " scores.`a45`,\n";
$sql .= " scores.`a46`,\n";
$sql .= " scores.`a47`,\n";
$sql .= " scores.`a48`,\n";
$sql .= " scores.`a49`,\n";
$sql .= " scores.`a50`,\n";
$sql .= " scores.`a51`,\n";
$sql .= " scores.`a52`,\n";
$sql .= " scores.`a53`,\n";
$sql .= " scores.`a54`,\n";
$sql .= " scores.`a55`,\n";
$sql .= " managers.`division`,\n";
$sql .= " managers.`name`\n";
$sql .= " From";
$sql .= " master master,";
$sql .= " quota quota,";
$sql .= " members members,";
$sql .= " bond bond,";
$sql .= " stocks stocks,";
$sql .= " services services,";
$sql .= " ins ins,";
$sql .= " ma ma,";
$sql .= " nh nh,";
$sql .= " goals goals,";
$sql .= " ballots ballots,";
$sql .= " votes votes,";
$sql .= " vacation vacation,";
$sql .= " essays essays,";
$sql .= " sales sales,";
$sql .= " sec sec,";
$sql .= " nom nom,";
$sql .= " hr hr,";
$sql .= " pto pto,";
$sql .= " mtg mtg,";
$sql .= " awards awards,";
$sql .= " inspect inspect,";
$sql .= " scores scores,";
$sql .= " managers managers";
$sql .= " Where (";
$sql .= " master.id = quota.id";
$sql .= " And master.id = members.id";
$sql .= " And master.id = bond.id";
$sql .= " And master.id = stocks.id";
$sql .= " And master.id = services.id";
$sql .= " And master.id = ins.id";
$sql .= " And master.id = ma.id";
$sql .= " And master.id = nh.id";
$sql .= " And master.id = goals.id";
$sql .= " And master.id = ballots.id";
$sql .= " And master.id = votes.id";
$sql .= " And master.id = vacation.id";
$sql .= " And master.id = essays.id";
$sql .= " And master.id = sales.id";
$sql .= " And master.id = sec.id";
$sql .= " And master.id = nom.id";
$sql .= " And master.id = hr.id";
$sql .= " And master.id = pto.id";
$sql .= " And master.id = mtg.id";
$sql .= " And master.id = awards.id";
$sql .= " And master.id = inspect.id";
$sql .= " And master.division = scores.division";
$sql .= " And master.division = managers.division";
$sql .= " )";
$sql .= " ";
$sql_ext .= " ORDER BY master.id * 1 ASC ";
$searchmode = array();
$stdsearchopt = array();
$sqlgrandtotal = "";
$sqlgrandtotal_ext = "";
$sqlgrandtotal .= " Select Count(*) FROM master master, quota quota, members members, bond bond, stocks stocks, services services, ins ins, ma ma, nh nh, goals goals, ballots ballots, votes votes, vacation vacation, essays essays, sales sales, sec sec, nom nom, hr hr, pto pto, mtg mtg, awards awards, inspect inspect, scores scores, managers managers
WHERE ( master.id = quota.id AND master.id = members.id AND master.id = bond.id AND master.id = stocks.id AND master.id = services.id AND master.id = ins.id AND master.id = ma.id AND master.id = nh.id AND master.id = goals.id AND master.id = ballots.id AND master.id = votes.id AND master.id = vacation.id AND master.id = essays.id AND master.id = sales.id AND master.id = sec.id AND master.id = nom.id AND master.id = hr.id AND master.id = pto.id AND master.id = mtg.id AND master.id = awards.id AND master.id = inspect.id AND master.division = scores.division AND master.division = managers.division ) ";
$searchmode[0] = 1;
$searchmode[1] = 1;
$searchmode[2] = 1;
$searchmode[3] = 1;
$searchmode[4] = 1;
$searchmode[5] = 1;
$searchmode[6] = 1;
$searchmode[7] = 1;
$searchmode[8] = 1;
$searchmode[9] = 1;
$searchmode[10] = 1;
$searchmode[11] = 1;
$searchmode[12] = 1;
$searchmode[13] = 1;
$searchmode[14] = 1;
$searchmode[15] = 1;
$searchmode[16] = 1;
$searchmode[17] = 1;
$searchmode[18] = 1;
$searchmode[19] = 1;
$searchmode[20] = 1;
$searchmode[21] = 1;
$searchmode[22] = 1;
$searchmode[23] = 1;
$searchmode[24] = 1;
$searchmode[25] = 1;
$searchmode[26] = 1;
$searchmode[27] = 1;
$searchmode[28] = 1;
$searchmode[29] = 1;
$searchmode[30] = 1;
$searchmode[31] = 1;
$searchmode[32] = 1;
$searchmode[33] = 1;
$searchmode[34] = 1;
$searchmode[35] = 1;
$searchmode[36] = 1;
$searchmode[37] = 1;
$searchmode[38] = 1;
$stdsearchopt[0]=0;
$stdsearchopt[1]=0;
$stdsearchopt[2]=0;
$stdsearchopt[3]=0;
$stdsearchopt[4]=0;
$stdsearchopt[5]=0;
$stdsearchopt[6]=0;
$stdsearchopt[7]=0;
$stdsearchopt[8]=0;
$stdsearchopt[9]=0;
$stdsearchopt[10]=0;
$stdsearchopt[11]=0;
$stdsearchopt[12]=0;
$stdsearchopt[13]=0;
$stdsearchopt[14]=0;
$stdsearchopt[15]=0;
$stdsearchopt[16]=0;
$stdsearchopt[17]=0;
$stdsearchopt[18]=0;
$stdsearchopt[19]=0;
$stdsearchopt[20]=0;
$stdsearchopt[21]=0;
$stdsearchopt[22]=0;
$stdsearchopt[23]=0;
$stdsearchopt[24]=0;
$stdsearchopt[25]=0;
$stdsearchopt[26]=0;
$stdsearchopt[27]=0;
$stdsearchopt[28]=0;
$stdsearchopt[29]=0;
$stdsearchopt[30]=0;
$stdsearchopt[31]=0;
$stdsearchopt[32]=0;
$stdsearchopt[33]=0;
$stdsearchopt[34]=0;
$stdsearchopt[35]=0;
$stdsearchopt[36]=0;
$stdsearchopt[37]=0;
$stdsearchopt[38]=0;
if(!$result = @mysql_query($sql . " " . $sql_ext . " limit 0,1")){
$err_string .= "<strong>Error:</strong>while connecting to database<br>" . mysql_error();
}
if ($err_string != "") {
print "<center><table border=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\" >";
print "<tr>";
print "<td height=\"80\" align=\"default\" bgcolor=\"#FFFFFF\">";
print "<font color=\"#000099\" size=\"2\">";
print $err_string;
print "</font>";
print "</td>";
print "</tr>";
print "</table></center>";
exit;
}
$filter_string = "";
$qry_string = "";
$i = 0;
$searchendkey = "";
$searchstartkey = "";
$hidden_tag = "";
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result);
$field_name = $meta->name;
$field_table = $meta->table;
$field_type = $meta->type;
if (($searchmode[$i])==0) { # 0 = Std, 1 = Advance
if (($stdsearchopt[$i])==0) { # 0=Contain , 1 = Equal : for standard mode
$searchstartkey = "%";
$searchendkey = "%";
}else {
$searchstartkey = "";
$searchendkey = "";
}
} else {
$searchstartkey= "";
$searchendkey = "";
}
if ((qsrequest("search_fd" . $i) != "") && (qsrequest("search_fd" . $i) != "*")) {
$idata = qsrequest("search_fd" . $i);
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<")) {
$iopt = "<=";
$irealdata = substr($idata, 2);
} elseif (($iopt == ">=") || ($iopt == "=>")) {
$iopt = ">=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "==") {
$iopt = "=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "<>") {
$irealdata = substr($idata, 2);
} else {
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
$irealdata = substr($idata,1);
} else {
$iopt = "=";
}
}
if (!strcasecmp($idata,"{current date and time}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current date}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current time}")) {
$idata = time();
}
if ($meta) {
if ((strtolower($field_type) == "timestamp")
||(strtolower($field_type) == "datetime")
||(strtolower($field_type) == "smalldatetime")
||(strtolower($field_type) == "date")
||(strtolower($field_type) == "time")
||(strtolower($field_type) == "year")) {
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if (($iopt)=="="){
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qsrequest("multisearch_fd" . $i) != "")) {
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . $conditionstr . " ". $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " ". $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
}
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Invalid DateTime.<br>";
}
} elseif (($meta->numeric) == 1) {
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata)) {
if ((qsrequest("multisearch_fd" . $i) != "")) {
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $idata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
} else {
$qry_string .= "&search_fd" . $i . "=" . $idata;
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
}
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
} elseif ((strtolower($field_type) == "blob")
||(strtolower($field_type) == "mediumblob")
||(strtolower($field_type) == "longblob")) {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . " Like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . " Like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
} elseif ((strtolower($field_type) == "varchar")
||(strtolower($field_type) == "char")
||(strtolower($field_type) == "text")
||(strtolower($field_type) == "tinytext")
||(strtolower($field_type) == "mediumtext")
||(strtolower($field_type) == "string")
||(strtolower($field_type) == "longtext")
||(strtolower($field_type) == "nvarchar")
||(strtolower($field_type) == "nchar")
||(strtolower($field_type) == "ntext")) {
if (($iopt)=="="){
$conditionstr = " Like ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qsrequest("multisearch_fd" . $i) != "")) {
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
}
}
} else {
if ((qsrequest("multisearch_fd" . $i) != "")) {
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
$irealdata = str_replace("%", "", $irealdata);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
}
}
}
}
if (qsrequest("search_fd_" . $i) != "") {
$idata = qsrequest("search_fd_" . $i);
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<")) {
$iopt = "<=";
$irealdata = substr($idata, 2);
} elseif (($iopt == ">=") || ($iopt == "=>")) {
$iopt = ">=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "==") {
$iopt = "=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "<>") {
$irealdata = substr($idata, 2);
} else {
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
$irealdata = substr($idata,1);
} else {
$iopt = "=";
}
}
if ($meta) {
if ((strtolower($field_type) == "timestamp")
||(strtolower($field_type) == "datetime")
||(strtolower($field_type) == "smalldatetime")
||(strtolower($field_type) == "date")
||(strtolower($field_type) == "time")
||(strtolower($field_type) == "year")) {
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if (($iopt)=="="){
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
}
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate .$searchstartkey . $irealdata . $searchendkey . $quotedate;
} else {
$qry_string .= "&search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
}
}
elseif ((strtolower($field_type) == "integer")
||(strtolower($field_type) == "int")
||(strtolower($field_type) == "smallint")
||(strtolower($field_type) == "tinyint")
||(strtolower($field_type) == "longint")
||(strtolower($field_type) == "counter")
||(strtolower($field_type) == "autoincrement")
||(strtolower($field_type) == "float")
||(strtolower($field_type) == "real")
||(strtolower($field_type) == "money")
||(strtolower($field_type) == "smallmoney")
||(strtolower($field_type) == "short")
||(strtolower($field_type) == "long")
||(strtolower($field_type) == "double")
||(strtolower($field_type) == "currency")
||(strtolower($field_type) == "bit")
||(strtolower($field_type) == "decimal")
||(strtolower($field_type) == "number")
||(strtolower($field_type) == "numeric")) {
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata)) {
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
} else {
$qry_string .= "&search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
}
}
}
$i++;
}
if ($result > 0) {mysql_free_result($result);}
if ($filter_string != "") {
$sql .= " and " . $filter_string;
$sqlgrandtotal .= " and " . $filter_string;
}
if (qsrequest("sortfield") != "") {
$sql = $sql . " Order By " . stripslashes(qsrequest("sortfield")) . " " . stripslashes(qsrequest("sortby"));
$sortstring = "&sortfield=" . qsrequest("sortfield") . "&sortby=" . qsrequest("sortby");
} else {
$sql = $sql . " " . $sql_ext;
}
$sqlgrandtotal = $sqlgrandtotal . " " . $sqlgrandtotal_ext;
$result = mysql_query($sql)
or die("Invalid query");
$num_rows = mysql_num_rows($result);
$grandtotal_result = mysql_query($sqlgrandtotal)
or die("Invalid query");
$grandtotal_num_rows = mysql_num_rows($grandtotal_result);
$current_page = 1;
$page_count = 1;
$page_size = 99999;
$page_number_style1 = $current_page . "/" . $page_count;
$page_number_style2 = "Page " . $current_page . " of " . $page_count;
?>
<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&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=3&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=4&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=5&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=6&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=7&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=8&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=9&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=10&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=11&&'>1</a>
<li><a href='http://www.mysite.com/totals.php?search_fd1=12&&'>1</a>
</ul>";
session_start();
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' : '').' </td>');
echo ('<td class=' . $css_class . ' align=default >'.($val[47] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[0].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[1].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[2].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[4].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[6].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[7].' </td>');
if ($val[9] == 'Y') $temp = 'X';
elseif ($val[9] == 'N') $temp = '';
else $temp = $val[9];
echo ('<td class=' . $css_class . ' align=default >'.$temp.' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[10] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[11] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[12] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[14] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[56] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[16] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[18].' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[20] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[22] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[24].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[25].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[26].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[27].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[28].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[29].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[31].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[33].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[35].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[37].' </td>');
echo ('<td class=' . $css_class . ' align=center >'.($val[39] == 'Y' ? 'X' : '').' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[52].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[53].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[54].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[41].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[43].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[49].' </td>');
echo ('<td class=' . $css_class . ' align=default >'.$val[50].' </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>
on the code above, you need to put session_start(); at the beginning of the file, before you write anything to the client. The same thing applies to all the files that are using sessions. You cannot save data on Session variables once you have sent output.
I provided a more complete explanation here:
https://www.experts-exchange.com/questions/22946413/How-to-solve-this-Session-Problem-detail-inside.html
https://www.experts-exchange.com/questions/22946413/How-to-solve-this-Session-Problem-detail-inside.html
ASKER
Hi,
I put session_start(); at the very beginning of the totals.php file, but it still does the same thing in the standings.php file.
I put session_start(); at the very beginning of the totals.php file, but it still does the same thing in the standings.php file.
You need it at the beginning of every file. Unless one #includes the other. Seriously, read the link provided.
ASKER
I looked at the example and saw that this was used:
session_start();
session_destroy();
I didn't see session_write_close(); being used. Do I get rid of that?
session_start();
session_destroy();
I didn't see session_write_close(); being used. Do I get rid of that?
session_destroy would technically "delete" the encrypted cookie from the server. So you do not need this because if you do so at the end of the file (say file1.php) you are essentially saying, I do not want the sessions to be visible anywhere else. You would typically use it on logout page.
From the manual: (http://us3.php.net/session_write_close)
"Session data is usually stored after your script terminated without the need to call session_write_close()". I have never used it and my pages have always worked. You can comment it out.
From the manual: (http://us3.php.net/session_write_close)
"Session data is usually stored after your script terminated without the need to call session_write_close()". I have never used it and my pages have always worked. You can comment it out.
ASKER
hielo,
Thanks for all of your help so far, but I am still getting the last four columns in the standings.php file with repeating results. I put session_start(); at the very beginning of the files and it still does the same thing.
Thanks for all of your help so far, but I am still getting the last four columns in the standings.php file with repeating results. I put session_start(); at the very beginning of the files and it still does the same thing.
do you have a gmail account. Chatting will be more productive. I only chat via gmail.
Are you sure the browser has cookies enabled? IF not, sessions will not work.
ASKER
Yes, cookies are enabled and I am using the newest version of Firefox. I do have a gmail account.
Does totals.php:
1. include("standings.php"); or
2. require_once("standings.ph p"); or
3. a form is submitted from standings.php and the data sent to standings.php?
1. include("standings.php"); or
2. require_once("standings.ph
3. a form is submitted from standings.php and the data sent to standings.php?
find these four lines:
$_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
and update your file so looks like this:
echo($sum3);//Basically you need to verify that $sum3 does infact have a value
$_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( $_SESSION["sum3"] );//verify that the value was stored in the session
If $sum3 has no value then you need to into it and once that is solved, the rest may fall into place.
$_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
and update your file so looks like this:
echo($sum3);//Basically you need to verify that $sum3 does infact have a value
$_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( $_SESSION["sum3"] );//verify that the value was stored in the session
If $sum3 has no value then you need to into it and once that is solved, the rest may fall into place.
ASKER
No, totals.php doesn't include standings.php nor does it require_once.
Also a form is not submitted on neither totals.php or standings.php
The only form that exists is in totals_search.php. I used it to do a search for each of the 12 DIVISIONS, copy and pasted the links in the totals.php file. That way as user can click on any of the links to view that DIVISION's data.
The totals.php file only displays the data and totals for one division at a time:
totals.php?search_fd1=1&&' > <-- DIVISION 1
totals.php?search_fd1=2&&' > <-- DIVISION 2
and so on...
The links look like this:
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>";
Also a form is not submitted on neither totals.php or standings.php
The only form that exists is in totals_search.php. I used it to do a search for each of the 12 DIVISIONS, copy and pasted the links in the totals.php file. That way as user can click on any of the links to view that DIVISION's data.
The totals.php file only displays the data and totals for one division at a time:
totals.php?search_fd1=1&&'
totals.php?search_fd1=2&&'
and so on...
The links look like this:
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>";
ASKER
We can use gmail like you suggested earlier. Like you said, it is more productive
I don't understand how you are "interconnecting" the files. Clicking any of the links above will always invoke totals.php. So, it is not clear where the application starts (entry page), not how all these files are interconnected if you do not use include nor require statements.
ASKER
hielo,
I to the following like you said:
and update your file so looks like this:
echo($sum3);//Basically you need to verify that $sum3 does infact have a value
$_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( $_SESSION["sum3"] );//verify that the value was stored in the session
But it didn't change anything in the standings.php file. It just added the sum3 total twice in the totals.php file
I to the following like you said:
and update your file so looks like this:
echo($sum3);//Basically you need to verify that $sum3 does infact have a value
$_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( $_SESSION["sum3"] );//verify that the value was stored in the session
But it didn't change anything in the standings.php file. It just added the sum3 total twice in the totals.php file
ASKER
Okay, this might be part of the problem. I don't know if this helps but it does require this in all three PHP files.
require('conn.php');
require('func.php'); <-- This file goes in all three PHP files, including conn.php
It was in there the whole time, but I forgot to include it on here. Sorry for the confusion. I hope this clears it up a bit. It still does the same thing though.
Here is the code for func.php if it helps any. If I don't include it in any of the files I get this error: Fatal error: Call to undefined function: qsrequest()
require('conn.php');
require('func.php'); <-- This file goes in all three PHP files, including conn.php
It was in there the whole time, but I forgot to include it on here. Sorry for the confusion. I hope this clears it up a bit. It still does the same thing though.
Here is the code for func.php if it helps any. If I don't include it in any of the files I get this error: Fatal error: Call to undefined function: qsrequest()
<?php
function qs_string_to_timestamp($str)
{
$l=strlen($str);
switch ($l) {
case 4:
$tm=qs_year_to_timestamp($str);
break;
case 8:
$tm=qs_time_to_timestamp($str);
break;
case 10:
$tm=qs_date_to_timestamp($str);
break;
case 14:
$tm=qs_timestamp_to_timestamp($str);
break;
case 19:
$tm=qs_datetime_to_timestamp($str);
break;
case 23:
$tm=qs_datetime_to_timestamp($str);
break;
default:
$tm=mktime(24,0,0,1,1,1970);
}
return $tm;
}
function qs_timestamp_to_timestamp($dt)
{
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,4,2));
$da=strval(substr($dt,6,2));
$hr=strval(substr($dt,8,2));
$mi=strval(substr($dt,10,2));
$se=strval(substr($dt,12,2));
return mktime($hr,$mi,$se,$mo,$da,$yr);
}
function qs_datetime_to_timestamp($dt)
{
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,5,2));
$da=strval(substr($dt,8,2));
$hr=strval(substr($dt,11,2));
$mi=strval(substr($dt,14,2));
$se=strval(substr($dt,17,2));
return @mktime($hr,$mi,$se,$mo,$da,$yr);
}
function qs_date_to_timestamp($dt)
{
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,5,2));
$da=strval(substr($dt,8,2));
$hr=0;
$mi=0;
$se=0;
return mktime($hr,$mi,$se,$mo,$da,$yr);
}
function qs_time_to_timestamp($dt)
{
$yr=1970;
$mo=1;
$da=1;
$hr=strval(substr($dt,0,2));
$mi=strval(substr($dt,3,2));
$se=strval(substr($dt,6,2));
return mktime($hr,$mi,$se,$mo,$da,$yr);
}
function qs_year_to_timestamp($dt)
{
$yr=strval(substr($dt,0,4));
$mo=1;
$da=1;
$hr=0;
$mi=0;
$se=0;
return mktime($hr,$mi,$se,$mo,$da,$yr);
}
function qs_datetime_to_string ($dt)
{
if (date("H:i:s",$dt) == "00:00:00") {
$str = date("n/j/Y",$dt);
} else {
$str = date("n/j/Y g:i:s",$dt);
}
return $str;
}
function qsvalid_timestamp($dt)
{
if (strlen($dt) == 14) {
$retval = is_numeric($dt);
} else {
$retval = false;
}
return $retval;
}
function qsvalidrequest ($paramval)
{
return (((isset($_GET[$paramval])) || (isset($_POST[$paramval]))) && (qsrequest($paramval)!=""));
}
function qsrequest ($paramval)
{
if (isset($_GET[$paramval])) {
$retval = $_GET[$paramval];
} elseif (isset($_POST[$paramval])) {
$retval = $_POST[$paramval];
} else {
$retval = "";
}
return $retval;
}
function qsservervars($paramval)
{
if (isset($_SERVER[$paramval])) {
$retval = $_SERVER[$paramval];
} else {
$retval = "";
}
return $retval;
}
function qssession($paramval)
{
if (isset($_SESSION[$paramval])) {
$retval = $_SESSION[$paramval];
} else {
$retval = "";
}
return $retval;
}
function arrayvalue($paramval,$search_array)
{
if (array_key_exists($paramval,$search_array)) {
$retval = $search_array[$paramval];
} else {
$retval = "";
}
return $retval;
}
function qsodbc_fetch_array($res,$row_num)
{
$row = array();
$result = array();
if ($row_num > 0) {
$result = odbc_fetch_row($res,$row_num);
} else {
$result = odbc_fetch_row($res);
}
if ($result) {
$nf = odbc_num_fields($res);
for($i=0; $i < $nf; $i++) {
$field_value = odbc_result($res, $i + 1);
$row[$i] = $field_value;
}
return $row;
}
}
function qsodbc_num_rows($res)
{
$rowcount = odbc_num_rows($res);
if ($rowcount < 0) {
$rowcount = 0;
while($temp = odbc_fetch_into($res,&$idata)){
$rowcount++;
}
}
return $rowcount;
}
function qscheckselected ($paramval, $itemval, $defaultval)
{
if (trim(strtoupper($paramval)) == trim(strtoupper($itemval))) {
$retval = $defaultval;
} else {
$retval = "";
}
return $retval;
}
function qsmysqlgen_radio_button($sql,$objname,$field1,$field2,$itemval)
{
$result = mysql_query($sql) or die("Invalid query");
$cellstr = "";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$cellstr .= "<input type=\"radio\" name=\"";
$cellstr .= $objname . "\" value=\"" . $row[$field1] . "\"";
$cellstr .= qscheckselected($row[$field1],$itemval,"Checked") . ">";
$cellstr .= $row[$field2] . "<br>";
}
mysql_free_result($result);
return $cellstr;
}
function qsmysqlgen_listbox($sql,$objname,$field1,$field2,$itemval)
{
$result = mysql_query($sql) or die("Invalid query");
$cellstr = "";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$cellstr .= "<option value=\"" . $row[$field1] . "\"";
$cellstr .= qscheckselected($row[$field1],$itemval,"Selected") . ">";
$cellstr .= $row[$field2] . "</option>";
}
mysql_free_result($result);
return $cellstr;
}
function qsodbcgen_radio_button($conn,$sql,$objname,$field1,$field2,$itemval)
{
$result = odbc_exec($conn,$sql) or die("Invalid query");
$cellstr = "";
while (odbc_fetch_row($result)) {
$cellstr .= "<input type=\"radio\" name=\"";
$cellstr .= $objname . "\" value=\"" . odbc_result($result,$field1) . "\"";
$cellstr .= qscheckselected(odbc_result($result,$field1),$itemval,"Checked") . ">";
$cellstr .= odbc_result($result,$field2) . "<br>";
}
odbc_free_result($result);
return $cellstr;
}
function qsodbcgen_listbox($conn,$sql,$field1,$field2,$itemval)
{
$result = odbc_exec($conn,$sql) or die("Invalid query");
$cellstr = "";
while (odbc_fetch_row($result)) {
$cellstr .= "<option value=\"" . odbc_result($result,$field1) . "\"";
$cellstr .= qscheckselected(odbc_result($result,$field1),$itemval,"Selected") . ">";
$cellstr .= odbc_result($result,$field2) . "</option>";
}
odbc_free_result($result);
return $cellstr;
}
function qsreplace_html_quote($itemval)
{
$retval = htmlspecialchars($itemval, ENT_QUOTES);
return $retval;
}
function qsreplace_quote($itemval)
{
$retval = addslashes($itemval);
return $retval;
}
function qsreplace_backslashes($itemval)
{
$retval = str_replace("\\","\\\\",$itemval);
return $retval;
}
function qsdestroysession()
{
$_SESSION = array();
session_destroy();
}
?>
I don't know if by "added the sum3 total twice" you meant $sum3 plus $sum3 or simply that it appears twice. If it appears twice, then that tells me that the Session variable is being set. The problem will be elsewhere. I suspect the real issue is: "are you even interconnecting these files"? You have to understand that I cannot guess how your application is set up. With your descriptions I can't help you.
ASKER
I simply mean that it just appears twice. I understand, its okay. I have posted the code for totals.php and func.php which is required for each of the 3 files.
The only code you haven't seen is standings.php and totals_search.php. Would it help, if I posted the code for those files?
The only code you haven't seen is standings.php and totals_search.php. Would it help, if I posted the code for those files?
post them, but make sure you are clear on which file is which.
ASKER
Here is the code for = totals_search.php
<?php
require('conn.php');
require('func.php');
@session_start();
$err_string = "";
$strkeyword = "";
$sortstring = "";
$sql = "";
$sql_ext = "";
$fields = array();
$fields[0] = "master.`id`";
$fields[1] = "master.`division`";
$fields[2] = "master.`location`";
$fields[3] = "quota.`id`";
$fields[4] = "quota.`quota`";
$arryitemvalue = array();
$arryitemvalue[0] = "";
$arryitemvalue[1] = "";
$arryitemvalue[2] = "";
$arryitemvalue[3] = "";
$arryitemvalue[4] = "";
$arryitemvalue[5] = "";
$arryitemvalue[6] = "";
$arryitemvalue[7] = "";
$arryitemvalue[8] = "";
$arryitemvalue[9] = "";
$arryitemvalue[10] = "";
$arryitemvalue[11] = "";
$arryitemvalue[12] = "";
$arryitemvalue[13] = "";
$arryitemvalue[14] = "";
$arryitemvalue[15] = "";
$arryitemvalue[16] = "";
$arryitemvalue[17] = "";
$arryitemvalue[18] = "";
$arryitemvalue[19] = "";
$arryitemvalue[20] = "";
$arryitemvalue[21] = "";
$arryitemvalue[22] = "";
$arryitemvalue[23] = "";
$arryitemvalue[24] = "";
$arryitemvalue[25] = "";
$arryitemvalue[26] = "";
$arryitemvalue[27] = "";
$arryitemvalue[28] = "";
$arryitemvalue[29] = "";
$arryitemvalue[30] = "";
$arryitemvalue[31] = "";
$arryitemvalue[32] = "";
$arryitemvalue[33] = "";
$arryitemvalue[34] = "";
$arryitemvalue[35] = "";
$arryitemvalue[36] = "";
$arryitemvalue[37] = "";
$arryitemvalue[38] = "";
$arryopt = array();
$arryopt[0] = "";
$arryopt[1] = "";
$arryopt[2] = "";
$arryopt[3] = "";
$arryopt[4] = "";
$arryopt[5] = "";
$arryopt[6] = "";
$arryopt[7] = "";
$arryopt[8] = "";
$arryopt[9] = "";
$arryopt[10] = "";
$arryopt[11] = "";
$arryopt[12] = "";
$arryopt[13] = "";
$arryopt[14] = "";
$arryopt[15] = "";
$arryopt[16] = "";
$arryopt[17] = "";
$arryopt[18] = "";
$arryopt[19] = "";
$arryopt[20] = "";
$arryopt[21] = "";
$arryopt[22] = "";
$arryopt[23] = "";
$arryopt[24] = "";
$arryopt[25] = "";
$arryopt[26] = "";
$arryopt[27] = "";
$arryopt[28] = "";
$arryopt[29] = "";
$arryopt[30] = "";
$arryopt[31] = "";
$arryopt[32] = "";
$arryopt[33] = "";
$arryopt[34] = "";
$arryopt[35] = "";
$arryopt[36] = "";
$arryopt[37] = "";
$arryopt[38] = "";
$sql .= " Select";
$sql .= " master.`id`,";
$sql .= " master.`division`,";
$sql .= " master.`city`,";
$sql .= " quota.`id`,";
$sql .= " quota.`quota`,";
$sql .= " From";
$sql .= " master master,";
$sql .= " quota quota,";
$sql .= " Where (";
$sql .= " master.id = quota.id";
$sql .= " )";
$sql .= " ";
$sql_ext .= " ORDER BY master.id ASC";
$result = mysql_query($sql . " " . $sql_ext . " limit 0,1")
or die("Invalid query");
if (isset($_POST["QS_Submit"])) {
$filter_string = "";
$qry_string = "";
$i = 0;
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result);
$field_name = $meta->name;
$field_type = $meta->type;
if ((qsrequest("search_fd" . $i) != "") && (qsrequest("search_fd" . $i) != "*")) {
$idata = qsrequest("search_fd" . $i);
if (strlen($idata) > 1) {
if ($idata[strlen($idata) - 1] == "*") {
$idata = substr($idata, 0, strlen($idata) - 1);
}
}
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
if (qsrequest("search_optfd".$i) != "") {
$idata = qsrequest("search_optfd". $i) . $idata ;
}
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<")) {
$iopt = "<=";
$irealdata = substr($idata, 2);
} elseif (($iopt == ">=") || ($iopt == "=>")) {
$iopt = ">=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "==") {
$iopt = "=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "<>") {
$irealdata = substr($idata, 2);
} elseif ($iopt == "^^") {
$iopt = "*";
$idata = $iopt . $irealdata . $iopt; // Contain
} elseif ($iopt == "^*") {
$iopt = "*";
$idata = $irealdata . $iopt; // Start With
} elseif ($iopt == "*^") {
$iopt = "*";
$idata = $iopt . $irealdata ; // End With
} else {
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
$irealdata = substr($idata,1);
} else {
$iopt = "=";
}
}
if (!strcasecmp($idata,"{current date and time}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current date}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current time}")) {
$idata = time();
}
if ($meta) {
if ((strtolower($field_type) == "timestamp")
||(strtolower($field_type) == "datetime")
||(strtolower($field_type) == "smalldatetime")
||(strtolower($field_type) == "date")
||(strtolower($field_type) == "time")
||(strtolower($field_type) == "year")) {
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode($idata);
$filter_string = $field_name . " " . $iopt . " '" . $irealdata . "'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode($idata);
$filter_string .= " and " . $field_name . " " . $iopt . " '" . $irealdata . "'";
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Invalid DateTime.<br>";
}
} elseif (($meta->numeric) == 1) {
if (is_numeric($irealdata)) {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $idata;
$filter_string = $field_name . " " . $iopt . " " . $irealdata;
} else {
$qry_string .= "&search_fd" . $i . "=" . $idata;
$filter_string .= " and " . $field_name . " " . $iopt . " " . $irealdata;
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
} elseif ((strtolower($field_type) == "blob")
||(strtolower($field_type) == "mediumblob")
||(strtolower($field_type) == "longblob")) {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $field_name . " like '%" . $irealdata . "%'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " and " . $field_name . " like '%" . $irealdata . "%'";
}
} elseif ((strtolower($field_type) == "varchar")
||(strtolower($field_type) == "char")
||(strtolower($field_type) == "text")
||(strtolower($field_type) == "tinytext")
||(strtolower($field_type) == "mediumtext")
||(strtolower($field_type) == "string")
||(strtolower($field_type) == "longtext")
||(strtolower($field_type) == "nvarchar")
||(strtolower($field_type) == "nchar")
||(strtolower($field_type) == "ntext")) {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $field_name . " like '" . $irealdata . "%'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " and " . $field_name . " like '" . $irealdata . "%'";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $field_name . " = '" . $irealdata . "'";
} else {
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " and " . $field_name . " = '" . $irealdata . "'";
}
}
}
}
if (qsrequest("multisearch_fd" . $i) != "") {
if ($qry_string == "") {
$qry_string = "multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
} else {
$qry_string = $qry_string . "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
}
}
if (qsrequest("search_fd_" . $i) != "") {
$idata = qsrequest("search_fd_" . $i);
if (strlen($idata) > 1) {
if ($idata[strlen($idata) - 1] == "*") {
$idata = substr($idata, 0, strlen($idata) - 1);
}
}
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
if (qsrequest("search_optfd_".$i) != "") {
$idata = qsrequest("search_optfd_". $i) . $idata ;
}
if ($meta) {
if ((strtolower($field_type) == "timestamp")
||(strtolower($field_type) == "datetime")
||(strtolower($field_type) == "smalldatetime")
||(strtolower($field_type) == "date")
||(strtolower($field_type) == "time")
||(strtolower($field_type) == "year")) {
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . urlencode($idata);
$filter_string = $field_name . " like '%" . $idata . "%'";
} else {
$qry_string .= "&search_fd_" . $i . "=" . urlencode($idata);
$filter_string .= " and " . $field_name . " like '%" . $idata . "%'";
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Invalid DateTime.<br>";
}
} elseif ((strtolower($field_type) == "integer")
||(strtolower($field_type) == "int")
||(strtolower($field_type) == "smallint")
||(strtolower($field_type) == "tinyint")
||(strtolower($field_type) == "longint")
||(strtolower($field_type) == "counter")
||(strtolower($field_type) == "autoincrement")
||(strtolower($field_type) == "float")
||(strtolower($field_type) == "real")
||(strtolower($field_type) == "money")
||(strtolower($field_type) == "smallmoney")
||(strtolower($field_type) == "short")
||(strtolower($field_type) == "long")
||(strtolower($field_type) == "double")
||(strtolower($field_type) == "currency")
||(strtolower($field_type) == "bit")
||(strtolower($field_type) == "decimal")
||(strtolower($field_type) == "number")
||(strtolower($field_type) == "numeric")) {
if (is_numeric($irealdata)) {
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . $idata;
$filter_string = $field_name . " " . $iopt . " " . $irealdata;
} else {
$qry_string .= "&search_fd_" . $i . "=" . $idata;
$filter_string .= " and " . $field_name . " " . $iopt . " " . $irealdata;
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
}
}
}
$i++;
}
if ($result > 0) {mysql_free_result($result);}
if (qsrequest("search_sort") <> "") {
$sortstring = qsrequest("search_sort");
}
if ($err_string == "") {
if ($qry_string != "") {
$URL="./totals.php?" . $qry_string . $sortstring;
} else {
$URL="./totals.php";
}
header ("Location: $URL");
exit;
}
} else {
$sortstring = "";
if (qsrequest("sortfield") != "") {
$sortstring = "&sortfield=" . urlencode(stripslashes(qsrequest("sortfield"))) . "&sortby=" . urlencode(stripslashes(qsrequest("sortby")));
}
$i=0;
while ($i < mysql_num_fields($result)) {
$strkeyword = "";
$iopt = "";
$idata = "";
if ((!isset($_GET["search_fd".$i])) && (!isset($_POST["search_fd".$i]))) {
$arryitemvalue[$i] = "";
$arryopt[$i]="";
} else {
# Check value for advance search
$idata = qsrequest("search_fd" . $i);
$iopt = substr($idata, 0, 2); // Get 2 of left keyword
if (($iopt == "<=") || ($iopt == "=<")){
$iopt = "<=";
$strkeyword = substr($idata, 2);
}elseif (($iopt == ">=") || ($iopt == "=>")){
$iopt = ">=";
$strkeyword = substr($idata, 2);
}elseif ($iopt == "==" ){
$iopt = "==";
$strkeyword = substr($idata, 2);
}elseif ($iopt == "<>"){
$strkeyword = substr($idata, 2);
} else {
$startstrdata = substr(qsrequest("search_fd" . $i),0,1) ;
$endstrdata = $idata[strlen(qsrequest("search_fd" . $i)) - 1];
if (($startstrdata != "%" ) && ($endstrdata != "%")){
if (($startstrdata == "<") || ($startstrdata == ">") || ($startstrdata == "=")) {
if ($startstrdata == "<") {
$strkeyword = str_replace("<","", qsrequest("search_fd" . $i)) ;
$iopt = "<";
}elseif($startstrdata == ">") {
$strkeyword = str_replace(">","", qsrequest("search_fd" . $i)) ;
$iopt = ">";
} else {
$strkeyword = str_replace("=","", qsrequest("search_fd" . $i)) ;
$iopt = "=";
}
}else {
$arryitemvalue[$i] = qsrequest("search_fd". $i);
$strkeyword = qsrequest("search_fd". $i);
}
}else {
if (($startstrdata == "%" ) && ($endstrdata == "%")) { # Contain Case
$startstrdata = str_replace("%","", qsrequest("search_fd" . $i)) ;
$strkeyword = substr(qsrequest("search_fd" . $i),1, (strlen(qsrequest("search_fd" . $i))-2));
$iopt = "^^" ;
}elseif (($startstrdata != "%" ) && ($endstrdata == "%")) { # Start With Case xx*
$strkeyword = substr(qsrequest("search_fd" . $i),0, (strlen(qsrequest("search_fd" . $i))-1));
$iopt = "^*";
}elseif (($startstrdata == "%" ) && ($endstrdata != "%")) { # End With Case *xx
$strkeyword = substr(qsrequest("search_fd" . $i),1, (strlen(qsrequest("search_fd" . $i))));
$iopt = "*^";
}
}// end eheck one charator
}//end of check 2 first character
$arryitemvalue[$i] = $strkeyword;
$arryopt[$i] = $iopt;
}
$i += 1;
}// end while
if ($result > 0) {mysql_free_result($result);}
}
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="search.css">
</head>
<body>
<Center>
<form name="QS_Search_Form" method="post" action="./totals_search.php">
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#D4D4D4">
<?php
if ($sortstring != "") {
print "<input name=\"search_sort\" type=\"hidden\" value=\"".$sortstring."\">";
}
?>
<tr>
<td colspan="2" class="ThRows">Search</td>
</tr>
<?php
$css_class = "\"odd\"";
if ($err_string != "") {
print "<tr>";
print "<td class=\"th2\"><strong>Error:</strong></td>";
print "<td class=" . $css_class . " align=Default>" . $err_string . "</td>";
print "</tr>";
}
?>
<tr>
<td class="row1">MASTER ID</td>
<?php
if ((!isset($_GET["search_fd0"])) && (!isset($_POST["search_fd0"]))) {
$itemvalue = "";
} else {
$itemvalue = qsrequest("search_fd0");
}
$cellvalue = "<select name=\"search_optfd0\"><option value=\"^^\"" . qscheckselected("^^",$arryopt[0],"selected") . ">contains</option><option value=\"^*\"" . qscheckselected("^*",$arryopt[0],"selected") . ">starts with</option><option value=\"*^\"" . qscheckselected("*^",$arryopt[0],"selected") . ">ends with</option><option value=\"==\"" . qscheckselected("==",$arryopt[0],"selected") . ">is equal to</option><option value=\"<>\"" . qscheckselected("<>",$arryopt[0],"selected") . ">is not equal to</option><option value=\"<\"" . qscheckselected("<",$arryopt[0],"selected") . ">is less than</option><option value=\"<=\"" . qscheckselected("<=",$arryopt[0],"selected") . ">is less than or equal to</option><option value=\">\"" . qscheckselected(">",$arryopt[0],"selected") . ">is greater than</option><option value=\">=\"" . qscheckselected(">=",$arryopt[0],"selected") . ">is greater than or equal to</option></select><input type=\"text\" name=\"search_fd0\" value=\"" . qsreplace_html_quote(stripslashes($arryitemvalue[0])) . "\">" . "<input type=\"hidden\" name=\"multisearch_fd0\" value=\"\">";
if ($cellvalue == "") {
$cellvalue = " ";
}
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td class="row1">DIVISION</td>
<?php
if ((!isset($_GET["search_fd1"])) && (!isset($_POST["search_fd1"]))) {
$itemvalue = "";
} else {
$itemvalue = qsrequest("search_fd1");
}
$cellvalue = "<select name=\"search_optfd1\"><option value=\"^^\"" . qscheckselected("^^",$arryopt[1],"selected") . ">contains</option><option value=\"^*\"" . qscheckselected("^*",$arryopt[1],"selected") . ">starts with</option><option value=\"*^\"" . qscheckselected("*^",$arryopt[1],"selected") . ">ends with</option><option value=\"==\"" . qscheckselected("==",$arryopt[1],"selected") . ">is equal to</option><option value=\"<>\"" . qscheckselected("<>",$arryopt[1],"selected") . ">is not equal to</option><option value=\"<\"" . qscheckselected("<",$arryopt[1],"selected") . ">is less than</option><option value=\"<=\"" . qscheckselected("<=",$arryopt[1],"selected") . ">is less than or equal to</option><option value=\">\"" . qscheckselected(">",$arryopt[1],"selected") . ">is greater than</option><option value=\">=\"" . qscheckselected(">=",$arryopt[1],"selected") . ">is greater than or equal to</option></select><input type=\"text\" name=\"search_fd1\" value=\"" . qsreplace_html_quote(stripslashes($arryitemvalue[1])) . "\">" . "<input type=\"hidden\" name=\"multisearch_fd1\" value=\"\">";
if ($cellvalue == "") {
$cellvalue = " ";
}
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td class="row1">LOCATION</td>
<?php
if ((!isset($_GET["search_fd2"])) && (!isset($_POST["search_fd2"]))) {
$itemvalue = "";
} else {
$itemvalue = qsrequest("search_fd2");
}
$cellvalue = "<select name=\"search_optfd2\"><option value=\"^^\"" . qscheckselected("^^",$arryopt[2],"selected") . ">contains</option><option value=\"^*\"" . qscheckselected("^*",$arryopt[2],"selected") . ">starts with</option><option value=\"*^\"" . qscheckselected("*^",$arryopt[2],"selected") . ">ends with</option><option value=\"==\"" . qscheckselected("==",$arryopt[2],"selected") . ">is equal to</option><option value=\"<>\"" . qscheckselected("<>",$arryopt[2],"selected") . ">is not equal to</option><option value=\"<\"" . qscheckselected("<",$arryopt[2],"selected") . ">is less than</option><option value=\"<=\"" . qscheckselected("<=",$arryopt[2],"selected") . ">is less than or equal to</option><option value=\">\"" . qscheckselected(">",$arryopt[2],"selected") . ">is greater than</option><option value=\">=\"" . qscheckselected(">=",$arryopt[2],"selected") . ">is greater than or equal to</option></select><input type=\"text\" name=\"search_fd2\" value=\"" . qsreplace_html_quote(stripslashes($arryitemvalue[2])) . "\">" . "<input type=\"hidden\" name=\"multisearch_fd2\" value=\"\">";
if ($cellvalue == "") {
$cellvalue = " ";
}
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td class="row1">QUOTA ID</td>
<?php
if ((!isset($_GET["search_fd3"])) && (!isset($_POST["search_fd3"]))) {
$itemvalue = "";
} else {
$itemvalue = qsrequest("search_fd3");
}
$cellvalue = "<select name=\"search_optfd3\"><option value=\"^^\"" . qscheckselected("^^",$arryopt[3],"selected") . ">contains</option><option value=\"^*\"" . qscheckselected("^*",$arryopt[3],"selected") . ">starts with</option><option value=\"*^\"" . qscheckselected("*^",$arryopt[3],"selected") . ">ends with</option><option value=\"==\"" . qscheckselected("==",$arryopt[3],"selected") . ">is equal to</option><option value=\"<>\"" . qscheckselected("<>",$arryopt[3],"selected") . ">is not equal to</option><option value=\"<\"" . qscheckselected("<",$arryopt[3],"selected") . ">is less than</option><option value=\"<=\"" . qscheckselected("<=",$arryopt[3],"selected") . ">is less than or equal to</option><option value=\">\"" . qscheckselected(">",$arryopt[3],"selected") . ">is greater than</option><option value=\">=\"" . qscheckselected(">=",$arryopt[3],"selected") . ">is greater than or equal to</option></select><input type=\"text\" name=\"search_fd3\" value=\"" . qsreplace_html_quote(stripslashes($arryitemvalue[3])) . "\">" . "<input type=\"hidden\" name=\"multisearch_fd3\" value=\"\">";
if ($cellvalue == "") {
$cellvalue = " ";
}
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td class="row1">QUOTA</td>
<?php
if ((!isset($_GET["search_fd4"])) && (!isset($_POST["search_fd4"]))) {
$itemvalue = "";
} else {
$itemvalue = qsrequest("search_fd4");
}
$cellvalue = "<select name=\"search_optfd4\"><option value=\"^^\"" . qscheckselected("^^",$arryopt[4],"selected") . ">contains</option><option value=\"^*\"" . qscheckselected("^*",$arryopt[4],"selected") . ">starts with</option><option value=\"*^\"" . qscheckselected("*^",$arryopt[4],"selected") . ">ends with</option><option value=\"==\"" . qscheckselected("==",$arryopt[4],"selected") . ">is equal to</option><option value=\"<>\"" . qscheckselected("<>",$arryopt[4],"selected") . ">is not equal to</option><option value=\"<\"" . qscheckselected("<",$arryopt[4],"selected") . ">is less than</option><option value=\"<=\"" . qscheckselected("<=",$arryopt[4],"selected") . ">is less than or equal to</option><option value=\">\"" . qscheckselected(">",$arryopt[4],"selected") . ">is greater than</option><option value=\">=\"" . qscheckselected(">=",$arryopt[4],"selected") . ">is greater than or equal to</option></select><input type=\"text\" name=\"search_fd4\" value=\"" . qsreplace_html_quote(stripslashes($arryitemvalue[4])) . "\">" . "<input type=\"hidden\" name=\"multisearch_fd4\" value=\"\">";
if ($cellvalue == "") {
$cellvalue = " ";
}
print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td colspan="2" class="rows" align=Center>
<input type="button" name="QS_Back" value="Back" OnClick="history.back()">
<input type="submit" name="QS_Submit" value="Run">
<input type="button" name="QS_Clear" value="Clear" OnClick="location='totals_search.php'">
</td>
</tr>
</table><br>
</form>
<?php
@mysql_close($link);
?>
</center>
</body>
</html>
ASKER
This is the code for = standings.php
<?php
session_start();
require ('conn.php');
require ('func.php');
$err_string = "";
$quotechar = "`";
$quotedate = "'";
$sql = "";
$sql_ext = "";
$cellvalue = "";
$istrdata = "";
$sortstring = "";
$fields = array();
$fields[0] = "master.id";
$fields[1] = "master.division";
$fields[2] = "quota.id";
$fields[3] = "quota.quota";
$fields[4] = "members.post";
$fields[5] = "members.total";
$fields[6] = "members.percentage";
$fields[7] = "scores.division";
$fields[8] = "scores.a55";
$fields[9] = "managers.division";
$fields[10] = "managers.name";
$sql .= " SELECT master.id,
master.division,
master.location,
quota.id,
quota.quota,
members.id,
members.total,
members.percentage,
scores.division,
scores.a55,
managers.division,
managers.name
FROM
master master,
quota quota,
members members,
scores scores,
managers managers
WHERE
master.id = quota.id
AND master.id = members.id
AND master.division = scores.division
AND master.division = managers.division
ORDER BY scores.a14 ASC";
$searchmode = array();
$stdsearchopt = array();
$sqlgrandtotal = "";
$sqlgrandtotal_ext = "";
$sqlgrandtotal .= " SELECT Count(*) FROM master master, quota quota, members members, scores scores, managers managers
WHERE ( master.id = quota.id AND master.id = members.id AND master.division = scores.division AND master.division = managers.division ) ";
if (!$result = @mysql_query($sql . " " . $sql_ext . " limit 0,1"))
{
$err_string .= "<strong>Error:</strong>while connecting to database<br>" .
mysql_error();
}
if ($err_string != "")
{
echo "<center><table border=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\" >";
echo "<tr>";
echo "<td height=\"80\" align=\"default\" bgcolor=\"#FFFFFF\">";
echo "<font color=\"#000099\" size=\"2\">";
echo $err_string;
echo "</font>";
echo "</td>";
echo "</tr>";
echo "</table></center>";
exit;
}
$filter_string = "";
$qry_string = "";
$i = 0;
$searchendkey = "";
$searchstartkey = "";
$hidden_tag = "";
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result);
$field_name = $meta->name;
$field_table = $meta->table;
$field_type = $meta->type;
if (($searchmode[$i]) == 0)
{ # 0 = Std, 1 = Advance
if (($stdsearchopt[$i]) == 0)
{ # 0=Contain , 1 = Equal : for standard mode
$searchstartkey = "%";
$searchendkey = "%";
}
else
{
$searchstartkey = "";
$searchendkey = "";
}
}
else
{
$searchstartkey = "";
$searchendkey = "";
}
if ((qsrequest("search_fd" . $i) != "") && (qsrequest("search_fd" . $i) != "*"))
{
$idata = qsrequest("search_fd" . $i);
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<"))
{
$iopt = "<=";
$irealdata = substr($idata, 2);
}
elseif (($iopt == ">=") || ($iopt == "=>"))
{
$iopt = ">=";
$irealdata = substr($idata, 2);
}
elseif ($iopt == "==")
{
$iopt = "=";
$irealdata = substr($idata, 2);
}
elseif ($iopt == "<>")
{
$irealdata = substr($idata, 2);
}
else
{
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "="))
{
$irealdata = substr($idata, 1);
}
else
{
$iopt = "=";
}
}
if (!strcasecmp($idata, "{current date and time}"))
{
$idata = time();
}
elseif (!strcasecmp($idata, "{current date}"))
{
$idata = time();
}
elseif (!strcasecmp($idata, "{current time}"))
{
$idata = time();
}
if ($meta)
{
if ((strtolower($field_type) == "timestamp") || (strtolower($field_type) ==
"datetime") || (strtolower($field_type) == "smalldatetime") || (strtolower($field_type) ==
"date") || (strtolower($field_type) == "time") || (strtolower($field_type) ==
"year"))
{
if ((($timestamp = strtotime($irealdata)) !== -1))
{
if (($iopt) == "=")
{
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
}
else
{
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qsrequest("multisearch_fd" . $i) != ""))
{
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",", $multisearch);
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " " . $quotedate .
$searchstartkey . $irealdata . $searchendkey . $quotedate;
}
$filter_string .= ")";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " " . $quotedate .
$searchstartkey . $irealdata . $searchendkey . $quotedate;
}
$filter_string .= ")";
}
}
else
{
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
}
}
}
else
{
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name .
"</strong>.<br>";
$err_string .= "Description: Invalid DateTime.<br>";
}
}
elseif (($meta->numeric) == 1)
{
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata))
{
if ((qsrequest("multisearch_fd" . $i) != ""))
{
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",", $multisearch);
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
}
}
else
{
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . $idata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
}
else
{
$qry_string .= "&search_fd" . $i . "=" . $idata;
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
}
}
}
else
{
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name .
"</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
}
elseif ((strtolower($field_type) == "blob") || (strtolower($field_type) ==
"mediumblob") || (strtolower($field_type) == "longblob"))
{
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . " Like '" . ereg_replace("'", "''", stripslashes
($irealdata)) . "'";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . " Like '" . ereg_replace("'", "''",
stripslashes($irealdata)) . "'";
}
}
elseif ((strtolower($field_type) == "varchar") || (strtolower($field_type) ==
"char") || (strtolower($field_type) == "text") || (strtolower($field_type) ==
"tinytext") || (strtolower($field_type) == "mediumtext") || (strtolower($field_type) ==
"string") || (strtolower($field_type) == "longtext") || (strtolower($field_type) ==
"nvarchar") || (strtolower($field_type) == "nchar") || (strtolower($field_type) ==
"ntext"))
{
if (($iopt) == "=")
{
$conditionstr = " Like ";
$istrdata = str_replace("=", "", $istrdata);
}
else
{
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qsrequest("multisearch_fd" . $i) != ""))
{
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",", $multisearch);
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
}
$filter_string .= ")";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
}
$filter_string .= ")";
}
}
else
{
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " '" . $searchstartkey .
ereg_replace("'", "''", stripslashes($irealdata)) . $searchendkey . "'";
}
}
}
else
{
if ((qsrequest("multisearch_fd" . $i) != ""))
{
$multisearch = qsrequest("multisearch_fd" . $i);
$searcharray = split(",", $multisearch);
$irealdata = str_replace("%", "", $irealdata);
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " = '" . ereg_replace("'", "''",
stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'",
"''", stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qsrequest("multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " = '" . ereg_replace("'", "''",
stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++)
{
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'",
"''", stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
}
}
else
{
if ($qry_string == "")
{
$qry_string = "search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . " like '" . ereg_replace("'", "''", stripslashes
($irealdata)) . "'";
}
else
{
$qry_string .= "&search_fd" . $i . "=" . urlencode(stripslashes($idata));
$filter_string .= " AND " . $fields[$i] . " like '" . ereg_replace("'", "''",
stripslashes($irealdata)) . "'";
}
}
}
}
}
if (qsrequest("search_fd_" . $i) != "")
{
$idata = qsrequest("search_fd_" . $i);
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<"))
{
$iopt = "<=";
$irealdata = substr($idata, 2);
}
elseif (($iopt == ">=") || ($iopt == "=>"))
{
$iopt = ">=";
$irealdata = substr($idata, 2);
}
elseif ($iopt == "==")
{
$iopt = "=";
$irealdata = substr($idata, 2);
}
elseif ($iopt == "<>")
{
$irealdata = substr($idata, 2);
}
else
{
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "="))
{
$irealdata = substr($idata, 1);
}
else
{
$iopt = "=";
}
}
if ($meta)
{
if ((strtolower($field_type) == "timestamp") || (strtolower($field_type) ==
"datetime") || (strtolower($field_type) == "smalldatetime") || (strtolower($field_type) ==
"date") || (strtolower($field_type) == "time") || (strtolower($field_type) ==
"year"))
{
if ((($timestamp = strtotime($irealdata)) !== -1))
{
if (($iopt) == "=")
{
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
}
else
{
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
}
if ($qry_string == "")
{
$qry_string = "search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
}
else
{
$qry_string .= "&search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey .
$irealdata . $searchendkey . $quotedate;
}
}
elseif ((strtolower($field_type) == "integer") || (strtolower($field_type) ==
"int") || (strtolower($field_type) == "smallint") || (strtolower($field_type) ==
"tinyint") || (strtolower($field_type) == "longint") || (strtolower($field_type) ==
"counter") || (strtolower($field_type) == "autoincrement") || (strtolower($field_type) ==
"float") || (strtolower($field_type) == "real") || (strtolower($field_type) ==
"money") || (strtolower($field_type) == "smallmoney") || (strtolower($field_type) ==
"short") || (strtolower($field_type) == "long") || (strtolower($field_type) ==
"double") || (strtolower($field_type) == "currency") || (strtolower($field_type) ==
"bit") || (strtolower($field_type) == "decimal") || (strtolower($field_type) ==
"number") || (strtolower($field_type) == "numeric"))
{
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata))
{
if ($qry_string == "")
{
$qry_string = "search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
}
else
{
$qry_string .= "&search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
}
}
else
{
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name .
"</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
}
}
}
$i++;
}
if ($result > 0)
{
mysql_free_result($result);
}
if ($filter_string != "")
{
$sql .= " and " . $filter_string;
$sqlgrandtotal .= " and " . $filter_string;
}
if (qsrequest("sortfield") != "")
{
$sql = $sql . " Order By " . stripslashes(qsrequest("sortfield")) . " " .
stripslashes(qsrequest("sortby"));
$sortstring = "&sortfield=" . qsrequest("sortfield") . "&sortby=" . qsrequest("sortby");
}
else
{
$sql = $sql . " " . $sql_ext;
}
$sqlgrandtotal = $sqlgrandtotal . " " . $sqlgrandtotal_ext;
$result = mysql_query($sql) or die("Invalid query");
$num_rows = mysql_num_rows($result);
$grandtotal_result = mysql_query($sqlgrandtotal) or die("Invalid query");
$grandtotal_num_rows = mysql_num_rows($grandtotal_result);
$current_page = 1;
$page_count = 1;
$page_size = 99999;
$page_number_style1 = $current_page . "/" . $page_count;
$page_number_style2 = "Page " . $current_page . " of " . $page_count;
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="standing.css">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<?php
if ($num_rows > 0)
{
?>
<?php
echo "<strong>Standings</strong> ";
echo "<br />";
echo "<table cellpadding=\'2\' cellspacing=\'0\'>";
echo "<tr>";
echo "<td class=\"ThRows\" >ORDER</td>";
echo "<td class=\"ThRows\" >DIVISION</td>";
echo "<td class=\"ThRows\" >MANAGER</td>";
echo "<td class=\"ThRows\" >QUOTA</td>";
echo "<td class=\"ThRows\" >MEMBERS</td>";
echo "<td class=\"ThRows\" >%QUOTA</td>";
echo "<td class=\"ThRows\" >SCORE</td>";
echo "</tr>";
session_start();
$query = "SELECT scores.division, scores.a55, managers.division, managers.name ".
"FROM scores, managers ".
"WHERE scores.division = managers.division";
$result = mysql_query($query);
if($result && mysql_num_rows($result) > 0)
{
$standings = 1;
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$resultArray = mysql_fetch_array($result);
echo ('<tr>');//first row
if (($rowcount%2) == 0) {
$css_class = "\"row\"";
} else {
$css_class = "\"alt\"";
}
echo ('<td class=' . $css_class . ' align=default >'.$standings.'</td>');
echo ('<td class=' . $css_class . ' align=default >' . $resultArray[0] . ' </td>');
echo ('<td class=' . $css_class . ' align=default >' . $resultArray[3] . ' </td>');
echo ('<td class=' . $css_class . ' align=default >' . $_SESSION["sum3"] .'</td>');
echo ('<td class=' . $css_class . ' align=default >' . $_SESSION["sum4"] .'</td>');
echo ('<td class=' . $css_class . ' align=default >' . round($_SESSION["avgdsum"],2) . '%</td>');
echo ('<td class=' . $css_class . ' align=default >' . round($_SESSION["scorestotal"],2) . '</td>');
echo ('</tr>');
$standings++;
} // end if results
$i++;
}
echo "</table>";
echo "<br />";
session_write_close();
?>
<?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>
Here is how these files should start:
<?php //totals.php
session_start();
require('conn.php');
//more code follows
<?php //totals_search.php
session_start();
require('conn.php');
require('func.php');
//more code follows
<?php //standings.php
session_start();
if ($num_rows > 0)
{
//more code follows
Also, and I think this might be the issue, you are not including the db connection file on standings.php
I suspect if should start as follows:
<?php //standings.php
session_start();
require('conn.php');
if ($num_rows > 0)
{
//more code follows
<?php //totals.php
session_start();
require('conn.php');
//more code follows
<?php //totals_search.php
session_start();
require('conn.php');
require('func.php');
//more code follows
<?php //standings.php
session_start();
if ($num_rows > 0)
{
//more code follows
Also, and I think this might be the issue, you are not including the db connection file on standings.php
I suspect if should start as follows:
<?php //standings.php
session_start();
require('conn.php');
if ($num_rows > 0)
{
//more code follows
ASKER
I tried everything like you said, but I still get the same results for the last four columns in standings.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all of your effort and help so far.
You suggested to do something like the following below. Can you show me an example of what I would put where you have the comment tags // ? I am a little confused on what to do there.
$total=array();
for every db record{
//compute the sum for the current record prior to this line
//store the computed value for the current record on an anonymous array and append to corresponding session
$_SESSION["sum3"] = array( strval("division" . $result["division"]) => $sum3);
You suggested to do something like the following below. Can you show me an example of what I would put where you have the comment tags // ? I am a little confused on what to do there.
$total=array();
for every db record{
//compute the sum for the current record prior to this line
//store the computed value for the current record on an anonymous array and append to corresponding session
$_SESSION["sum3"] = array( strval("division" . $result["division"]) => $sum3);
If you want, create an email account at gmail the post here or on your profile. Once I get your email account I'll contact you so we can chat via google. It seems you are still very confused.
ASKER
Thanks hielo,
Get my email from my profile.
Get my email from my profile.
Check your email
ASKER
Please let me know if I need to post the code for the other PHP files.