#!/export/ch4/cgi-bin/php # mSQL.cgi executes an SQL query on a mSQL database 1998 Pennsylvania Special Olympics Summer Games \n"; echo "\n"; echo msql_result($results,$i,"athlete"); echo "\n"; echo "\n"; echo msql_result($results,$i,"county"); echo "\n"; echo "\n"; $s = msql_result($results,$i,"best_score"); if ($s == "0") { echo " "; } else { echo "$s"; } echo "\n"; echo "\n"; $s = msql_result($results,$i,"total_score"); if ($s == "0") { echo " "; } else { echo "$s"; } echo "\n"; echo "\n"; echo msql_result($results,$i,"time"); echo "\n"; echo "\n"; echo msql_result($results,$i,"place"); echo "\n"; echo "\n"; $i++; endwhile; } return($num); ); function print_error $error,$ask ( echo "
\n"; echo "

mSQL Error!

"; echo "
"; echo "$error\n"; echo "

\n"; echo "$ask\n"; mail("jwc@page.hrb.com","MSQL Error",$error); mail("john@cieply.com","MSQL Error","$error\n\n$ask"); ); > Last updated 0) { $time = msql_result($results,($num-1),"update_time"); msql_FreeResult($result); echo Date("D M d, Y @ h:m:s A",$time); } else { echo "

\n"; $SEARCH = ""; $CHOICE = ""; $SELECT =""; } } >

  $num records were found searching for '$SEARCH'

\n"; if ($num > 0) { echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; } /* Display all the found entries */ $i = 0; while ($i<$num); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $i++; endwhile; if ($num > 0) { echo "
AthleteCountySportEventBest
Score
Total
Score
TimePlace
\n"; echo msql_result($results,$i,"athlete"); echo "\n"; echo msql_result($results,$i,"county"); echo "\n"; echo msql_result($results,$i,"sport"); echo "\n"; echo msql_result($results,$i,"event"); echo "\n"; $s = msql_result($results,$i,"best_score"); if ($s == "0") { echo " "; } else { echo "$s"; } echo "\n"; $s = msql_result($results,$i,"total_score"); if ($s == "0") { echo " "; } else { echo "$s"; } echo "\n"; echo msql_result($results,$i,"time"); echo "\n"; echo msql_result($results,$i,"place"); echo "
\n"; } echo "
\n"; if ($ddbtable == "folympics"); Include("fallsearch.shtml"); else; Include("search.shtml"); endif; } /* Display the Selected fields */ } elseif ($SELECT) { $lookup = ""; /* if ($county) { $lookup += ",county = '$county'"; } elseif ($sport) { $lookup += ",sport = '$sport'"; } elseif ($athlete) { $lookup += ",athlete = '$athlete'"; } elseif ($event) { $lookup += ",event = '$event'"; } $lookup = ereg_replace("^,","",$lookup); */ if ($county) { $lookup += "AND county = '$county'"; } if ($sport) { $lookup += "AND sport = '$sport'"; } if ($athlete) { $lookup += "AND athlete = '$athlete'"; } if ($event) { $lookup += "AND event = '$event'"; } $lookup = ereg_replace("^AND","",$lookup); /* Display the Athlete results */ if ($sort == "results") { echo "$sport, $event Results

\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; $cnt = 0; $cnt += show_entry($ddbtable,$sport,$event,"Gold"); $cnt += show_entry($ddbtable,$sport,$event,"Silver"); $cnt += show_entry($ddbtable,$sport,$event,"Bronze"); $cnt += show_entry($ddbtable,$sport,$event,"Fourth"); $cnt += show_entry($ddbtable,$sport,$event,"Fifth"); $cnt += show_entry($ddbtable,$sport,$event,"Sixth"); $cnt += show_entry($ddbtable,$sport,$event,"Participant"); echo "
AthleteCountyBest
Score
Total
Score
TimePlace
\n";; if ($cnt == 0) { echo "
\n"; echo "

 

\n"; } /* Show results by County */ } else { $query = "SELECT DISTINCT county,sport,athlete,event,best_score,total_score,time,place,update_time FROM $ddbtable WHERE $lookup ORDER BY county,athlete,sport,event"; $results = msql("3wz",$query); if ($results == -1) { print_error ($phperrmsg,$query); } else { $num = msql_numrows($results); $COUNTY = ""; while ($i<$num); /* Print Unique Counties */ $newC = msql_result($results,$i,"county"); if ($newC != $COUNTY) { if ($COUNTY) { echo "\n"; echo "

 

\n"; } $COUNTY=$newC; echo "$COUNTY Athletes\n"; echo "

\n"; } } /* Give Them Choices */ } elseif ($CHOICE) { $lookup=$CHOICE; $mod = 2; if ($CHOICE == "county") { echo "

This option will allow you to view the results of all athletes for selected county. Please select one of the following counties to display:

\n"; } elseif ($CHOICE == "event") { echo "

This option will allow you to view the results of all athletes entered in the selected event. The results will be sorted by county. Please select one of the events to display:

\n"; $lookup= "sport,event"; } elseif ($CHOICE == "results") { $CHOICE = "event"; echo "

This option will allow you to view the results of all athletes entered in the selected event. The results will be sorted by finishing order. The following results have been entered into the database:

\n"; $lookup= "sport,event"; $extra="&sort=results"; $addlookup = "where place = 'Gold'"; } elseif ($CHOICE == "athlete") { Include("athletes.shtml"); echo "

Select the $CHOICE to view

\n"; if ($LASTNAME) { $addlookup = "where athlete like '^$LASTNAME%'"; } } else { echo "

Select the $CHOICE to view

\n"; } $width = 400/$mod; $query = "SELECT DISTINCT $lookup FROM $ddbtable $addlookup ORDER BY $lookup"; $results = msql("3wz",$query); if ($results == -1) { print_error ($phperrmsg,$query); } else { echo "\n"; $num = msql_numrows($results); $i = 0; $last = "None"; while ($i<$num); $row = $i % $mod; $pick = msql_result($results,$i,$CHOICE); $param = UrlEncode($pick); if (($CHOICE == "event") || ($CHOICE == "results")) { $sport = msql_result($results,$i,"sport"); $sport = UrlEncode($sport); $param = "$CHOICE=$param&sport=$sport&ddbtable=$ddbtable"; } else { $param = "$CHOICE=$param&ddbtable=$ddbtable"; } if ($CHOICE == "event") { $sport = msql_result($results,$i,"sport"); if ($last != $sport) { if ($i > 0) { echo "\n"; } echo "\n"; $last = $sport; echo "\n"; $row = -1; } } if ($row == 0) { if ($i > 0) { echo "\n"; } echo "\n"; } echo "\n"; $i++; endwhile; echo "\n"; echo "

$sport

\n"; echo "$pick\n"; echo "
\n"; } } msql_FreeResult($result); >