Records

[insert_php] printf(“
“);
printf(“

\n”);
printf(“

\n”);
printf(“

— Select from the following options–

\n”);
printf(“
“);
printf(“

“);
printf(“

\n”);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
# printf(“

“);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf ( “

\n” );
printf ( “

\n” );

printf(“

\n”);
printf(“

\n” );
printf ( “

\n” );
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf( “

\n” );

printf ( “

\n” );
$query=”SELECT * FROM clubs ORDER BY name”;
$clubs = mysql_query($query);
$num_clubs = mysql_num_rows($clubs);
printf(“

\n” );
printf ( “

\n” );
printf ( “

\n” );
printf( “

\n” );

printf ( “

\n” );

printf ( “

\n” );

printf(“

\n”);
printf(“

” );
if ( strlen( $hist ) == 0 or $hist == “C” )
{
printf ( “ Current
” );
printf ( “ History
” );
}
else
{
printf ( “ Current
” );
printf ( “ History
” );
}
printf ( “
” );

if ( strlen( $type ) == 0 or $type == “0” )
{
printf ( “ Individual
” );
printf ( “ Relay” );
}
else
{
printf ( “ Individual
” );
printf ( “ Relay” );
}

printf ( “

“);
if (strlen($course) == 0 or $course == “LC”)
{
printf(“Long Course
“);
printf(“Short Course”);
}
else
{
printf(“Long Course
“);
printf(“Short Course”);
}
printf(“
“);
if ( strlen( $gender ) == 0 or $gender == “F” )
{
printf ( “ Female
” );
printf ( “ Male
” );
printf ( “ Mixed” );
}
else if ( $gender == “M” )
{
printf ( “ Female
” );
printf ( “ Male
” );
printf ( “ Mixed” );
}
else if ( $gender == “X” )
{
printf ( “ Female
” );
printf ( “ Male
” );
printf ( “ Mixed” );
}
printf ( “
Age Group
” );

printf ( “

\n”);
printf(“
\n” );
printf( “
Name ” );
printf ( “” );
printf ( “
” );
printf(“
Sort By
” );
printf( “
” );
printf ( “
\n” );
printf ( “” );
printf ( “
\n” );
printf ( “

\n”);
if ( isset( $_GET[ “hist” ] ) )
{
$hist = $_GET[ “hist” ];
$type = $_GET[ “type” ];
$course = $_GET[ “course” ];
$gender = $_GET[ “gender” ];
$group = $_GET[ “group” ];
$filter = $_GET[ “filter” ];
$type = $_GET[ “type” ];
$holder = $_GET[ “holder” ];
$dist = $_GET[ “dist” ];
$stroke = $_GET[ “stroke” ];
$sorton = $_GET[ “sorton” ];

$query = “SELECT DATE_FORMAT(date, ‘%d-%m-%Y’) as fdate, givenname, surname, time, agebot, agetop, if(agetop, agetop, 99) as sortage, class, distance, course, sex, stroke, relay, description, clubs.sname as clubname, strokes.sname as strokename, pools.sname as poolname FROM (((records INNER JOIN clubs ON records.club = clubs.index) INNER JOIN strokes ON records.stroke = strokes.index) INNER JOIN pools ON records.venue=pools.index)”;
if ($hist==”C”)
{
$query = $query.” INNER JOIN (SELECT min(time) as minoftime, agebot as agebot1, agetop as agetop1, class as class1, distance as distance1, course as course1, sex as sex1, stroke as stroke1 FROM records GROUP BY sex1, agebot1, agetop1, class1, distance1, stroke1, course1 ORDER BY course1, sex1, stroke1, class1, agebot1, agetop1, distance1) as recs ON (time = minoftime) AND (agebot = agebot1) AND (agetop = agetop1) AND (class = class1) AND (distance = distance1) AND (course = course1) AND (sex = sex1) AND (stroke = stroke1)”;
$title = “Current”;
}
else
{
$title = “Historical”;
}
switch ($gender)
{
case “F”:
$sex=”1″;
$title = $title.” Female”;
break;
case “M”:
$sex=”0″;
$title = $title.” Male”;
break;
case “X”:
$sex=”2″;
$title = $title.” Mixed”;
break;
}
$query = $query.” WHERE records.sex = ‘$sex'”;
if ($course==”LC”)
{
$crse=”0″;
$title = $title.” LC Records”;
}
else
{
$crse=”1″;
$title = $title.” SC Records”;
}
$query = $query.” AND records.course = ‘$crse'”;
if ($type==”1″)
{
$query = $query.” AND records.relay = ‘1’”;
$title = $title.” – Relay”;
}
else
{
$query = $query.” AND records.relay = ‘0’”;
}
if ($dist!=”All”)
{
$query = $query.” AND records.distance = ‘$dist'”;
$title = $title.” – “.$dist.”m”;
}
if ($stroke!=”All”)
{
$query = $query.” AND records.stroke = ‘$stroke'”;
# $title = $title.” – “.$stroke;
}
$groupbits = explode(‘-‘, $group);
switch ($groupbits[0])
{
case “All”:
break;
case “Open”:
$query = $query.” AND records.class = 4″;
break;
case “U”:
$query = $query.” AND records.class = 1 AND records.agetop = “.$groupbits[1];
break;
case “O”:
$query = $query.” AND records.class = 3 AND records.agebot = “.$groupbits[1];
break;
case is_numeric($groupbits[0]):
$query = $query.” AND records.class = 0 AND records.agebot = “.$groupbits[0];
break;
}
if ($filter!=”All”)
{
$query = $query.” AND records.club = ‘$filter'”;
}
$holder = str_replace(“*”, “”, $holder);
$holder = str_replace(“%”, “”, $holder);
if (strlen($holder) != 0)
{
$query = $query.” AND records.surname REGEXP ‘”.$holder.”‘”;
}
switch ($sorton)
{
case “0”:
$orderby=”ORDER BY sortage, class, distance, stroke, date DESC”;
break;
case “1”:
$orderby=”ORDER BY sortage, class, stroke, distance, date DESC”;
break;
case “2”:
$orderby=”ORDER BY stroke, distance, sortage, class, date DESC”;
break;
case “3”:
$orderby=”ORDER BY surname, givenname, date DESC”;
break;
case “4”:
$orderby=”ORDER BY date DESC”;
break;
}

$query = $query. $orderby;

$result = mysql_query($query);
$num_results = mysql_num_rows($result);

printf(“

\n”);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

“);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
if ($type==”0″)
{
printf(“

\n”);
printf(“

\n”);
}
else
{
printf(“

\n”);
printf(“

\n”);
}
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
printf(“

\n”);
for ($i=0; $i < $num_results; $i++) { $row = mysql_fetch_array($result); echo "

“;
}
printf(“

\n”);
printf(“
\n”);
printf(“%s\n”, $title);
printf(“
\n”);
printf(“Updated: %s\n”, $updated);
printf(“
Name Surname Club Pool
Date
Time
“;
switch ($row[“class”])
{
case “0” :
echo htmlspecialchars(stripslashes($row[“agebot”])).”yrs”;
break;
case “1” :
echo htmlspecialchars(stripslashes($row[“agetop”])).”yrs&U”;
break;
case “2” :
echo htmlspecialchars(stripslashes($row[“agebot”].”-“.$row[“agetop”]));
break;
case “3” :
echo htmlspecialchars(stripslashes($row[“agebot”])).”yrs&O”;
break;
case “4” :
echo “Open”;
break;
}
echo “
“;
echo htmlspecialchars(stripslashes($row[“distance”])).”m”;
echo “
“;
echo “
“;
echo htmlspecialchars(stripslashes($row[“strokename”]));
echo “
“;
if ($type==”0”)
{
echo htmlspecialchars(stripslashes($row[“givenname”]));
}
else
{
echo htmlspecialchars(stripslashes($row[“description”]));
}
echo “
“;
echo htmlspecialchars(stripslashes($row[“surname”]));
echo “
“;
echo htmlspecialchars(stripslashes($row[“clubname”]));
echo “
“;
echo htmlspecialchars(stripslashes($row[“poolname”]));
echo “
“;
echo htmlspecialchars(stripslashes($row[“fdate”]));
echo “
“;
echo htmlspecialchars(stripslashes($row[“time”]));
echo “

\n”);
}
[/insert_php]