<?php
	require_once('config.php');
	
	$date = date("Y-m-d");
	$datetime = date("Y-m-d H:i:s");
	
	//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}		
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>California International Marathon -- Flash Results, Inc.</title>

<style type="text/css">
A.link:visited { text-decoration:none; color: #000000; }
A.link { text-decoration:none; color:#000000; }
A.link:hover { text-decoration:none; color:#000000; }

A.info:visited { text-decoration:underline; color: #000000; }
A.info { text-decoration:underline; color:#000000; }
A.info:hover { text-decoration:none; color:#000000; }

.outside td { border-right:solid 1px #d5d5d5;border-left:solid 1px #d5d5d5; }

.bottom td { border-top:solid 1px #d5d5d5; }

.counter { border-right:solid 1px #000066; border-left:solid 1px #000066; border-top:solid 1px #000066; border-bottom:solid 1px #000066; }

.bottominside td { border-top:solid 0px #d5d5d5; }

.noborder td { border-left:solid 0px #d5d5d5;border-right:solid 0px #d5d5d5; }
</style>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width='100%' bgcolor='#ffcc33' border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
    	<td width='100%'>
        
        	<table width='1000' align='center'>
            	<tr>
            		<td width='350' align='left'>
                    <font face='calibri' color='#000066' size='+1'><b>California International Marathon</b></font>
            		</td>

            		<td width='100' align='center' onmouseover="this.style.backgroundColor='#ffe188'" onmouseout="this.style.backgroundColor='#ffcc33'">
                    <a href='http://www.flashresults.com/2011_Meets/CIM/' class='link'>
                    <font face='calibri' color='#000066'>Home</font>
                    </a>
            		</td>


            		<td width='150' align='center' onmouseover="this.style.backgroundColor='#ffe188'" onmouseout="this.style.backgroundColor='#ffcc33'">
                    <a href='http://www.flashresults.com/2011_Meets/CIM/searchrelay/' class='link'>
                    <font face='calibri' color='#000066'>Relay Results</font>
                    </a>
            		</td>

            		<td width='150' align='center' onmouseover="this.style.backgroundColor='#ffe188'" onmouseout="this.style.backgroundColor='#ffcc33'">
                    <a href='http://www.flashresults.com/2011_Meets/CIM/searchind/' class='link'>
                    <font face='calibri' color='#000066'>Marathon Results</font>
                    </a>
            		</td>

            		<td width='150' align='center' onmouseover="this.style.backgroundColor='#ffe188'" onmouseout="this.style.backgroundColor='#ffcc33'">
                    <a href='http://www.flashresults.com/2011_Meets/CIM/leaderboards/' class='link'>
                    <font face='calibri' color='#000066'>Leaderboard</font>
                    </a>
            		</td>

            		<td width='150' align='center' onmouseover="this.style.backgroundColor='#ffe188'" onmouseout="this.style.backgroundColor='#ffcc33'">
                    <a href='http://www.flashresults.com/2011_Meets/CIM/athletetracking/' class='link'>
                    <font face='calibri' color='#000066'>Athlete Tracking</font>
                    </a>
            		</td>

            	</tr>
            </table>
        
        
        </td>
    </tr>

</table>


<table width='1000' align='center' class='outside'>
	<tr>
		<td width='100%'>


			<table width='99%' class='noborder' border='0' align='center'>
            	<tr>
                	<td width='100%' valign='top'>
                       <br />   
                       


<table width='975' align='center'>
<tr>
<td width='50%' align='center'>
<font face='calibri' size='+3'>California International Marathon</font><br>
<font face='calibri' size='+2'><i>Sacramento, CA</i></font><br>
<font face='calibri' size='+2'><b>Marathon Results</b></font>
</td>

<td width='50%'>


<?php
$result5 = mysql_query("SELECT * FROM runnermaster");
$num_rows5 = mysql_num_rows($result5);

$result6 = mysql_query("SELECT * FROM runnermaster WHERE Sex = 'M'");
$num_rows6 = mysql_num_rows($result6);

$result7 = mysql_query("SELECT * FROM runnermaster WHERE Sex = 'F'");
$num_rows7 = mysql_num_rows($result7);

echo "
<table width='100%' align='center' class='counter' bgcolor='#fee8a6'>
<tr>
<td width='100%'>
&nbsp;&nbsp;<font face='calibri'><b>Total Finishers:</b> $num_rows5<br>
&nbsp;&nbsp;<font face='calibri'><b>Male Finishers:</b> $num_rows6<br>
&nbsp;&nbsp;<font face='calibri'><b>Women Finishers:</b> $num_rows7<br>
</td>
</tr>
</table>";


?>

</td>
</tr>
</table>





<table width='975' align='center'>
<tr>
<td width='100%'>

<table width='975'>

		<tr>
		<td width='975' valign='top' align='center'>
        <br>
<font face='calibri' size='+2'>
<a href='SearchResultsMarathon-form.php' class='info'>Search Again</a>
</font>
<br><br>
<table width='975' border='0' cellspacing='0' cellpadding='0'>



<?php

  $fname = mysql_real_escape_string($fname);
    $lname = mysql_real_escape_string($lname);
	  $city = mysql_real_escape_string($city);
	    $division = mysql_real_escape_string($division);

$result1 = mysql_query("SELECT * FROM runnermaster WHERE FirstName LIKE '$fname%' AND LastName LIKE '$lname%' AND City LIKE '$city%' AND State LIKE '$state%' AND Division LIKE '$division%' AND Sex LIKE '$sex%' AND Country LIKE '$country%'");
$num_rows = mysql_num_rows($result1);

$result = mysql_query("SELECT * FROM runnermaster WHERE FirstName LIKE '$fname%' AND LastName LIKE '$lname%' AND City LIKE '$city%' AND State LIKE '$state%' AND Division LIKE '$division%' AND Sex LIKE '$sex%' AND Country LIKE '$country%' ORDER BY Place LIMIT $l,100");

if($l == '0')
	{$DispL = "1";}
		else{$DispL = ($l + 1);}

if($h > $num_rows)
	{$DispH = "$num_rows";}
		else{$DispH = "$h";}

$LinkLow = ($l + 100);
$LinkHigh = ($h + 100);

$PrevLinkLow = ($l - 100);
$PrevLinkHigh = ($h - 100);

echo "
<tr>
	<td colspan='6'><font face='calibri'><b>$num_rows Results Found</b></font></td>";
	
	
	
if($l == '0' & $num_rows > $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><b>Current Displaying $DispL-$DispH</b> | <a href='SearchResultsMarathon-view.php?l=$LinkLow&h=$LinkHigh' class='info'>Next 100</a></font></td>";		
	}
elseif($l == '0' & $num_rows < $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><b>Current Displaying $DispL-$DispH</b></font></td>";
	}
elseif($l > '0' & $num_rows > $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><a href='SearchResultsMarathon-view.php?l=$PrevLinkLow&h=$PrevLinkHigh' class='info'>Previous 100</a> | <b>Current Displaying $DispL-$DispH</b> | <a href='SearchResultsMarathon-view.php?l=$LinkLow&h=$LinkHigh' class='info'>Next 100</a></font></td>";
	}	
elseif($num_rows < $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><a href='SearchResultsMarathon-view.php?l=$PrevLinkLow&h=$PrevLinkHigh' class='info'>Previous 100</a> | <b>Current Displaying $DispL-$DispH</b></font></td>";
	}		
	
	
	
echo "	
</tr>


<tr bgcolor='#ffcc33'>
	<td width='50'><font face='calibri' color='#000066'><b>Place</b></font></td>
	<td width='250'><font face='calibri' color='#000066'><b>Name</b></font></td>
	<td width='50' align='center'><font face='calibri' color='#000066'><b>Sex</b></font></td>
	<td width='50' align='center'><font face='calibri' color='#000066'><b>Age</b></font></td>
	<td width='100' align='left'><font face='calibri' color='#000066'><b>Division</b></font></td>
	<td width='150' align='center'><font face='calibri' color='#000066'><b>Div Place</b></font></td>
	<td width='150' align='center'><font face='calibri' color='#000066'><b>Sex Place</b></font></td>
	<td width='200'><font face='calibri' color='#000066'><b>City</b></font></td>
	<td width='75' align='left'><font face='calibri' color='#000066'><b>State</b></font></td>
	<td width='75' align='center'><font face='calibri' color='#000066'><b>Time</b></font></td>
	<td width='75' align='center'><font face='calibri' color='#000066'><b>Pace</b></font></td>
	<td width='100' align='center'><font face='calibri' color='#000066'><b>Net Time</b></font></td>
</tr>";





$line=2;

while($row = mysql_fetch_array($result))
  {

$line=3-$line;

if($line == "1")
     {
echo "
<tr onmouseover=\"this.style.backgroundColor='#d3d3d3'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">
<td width='50'><font face='calibri' size='-1'>" . $row['Place'] . "</td>
<td width='250'><font face='calibri' size='-1'><a href='ViewResultsMarathon.php?Bib=" . $row['BibNum'] . "&fname=$fname&lname=$lname&city=$city&state=$state&division=$division&sex=$sex&l=$l&h=$h' class='info'>" . $row['FirstName'] . " " . $row['LastName'] . "</a></td>
<td width='50' align='center'><font face='calibri' size='-1'>" . $row['Sex'] . "</td>
<td width='50' align='center'><font face='calibri' size='-1'>" . $row['Age'] . "</td>
<td width='100' align='left'><font face='calibri' size='-1'>" . $row['Division'] . "</td>
<td width='150' align='center'><font face='calibri' size='-1'>" . $row['DivPlace'] . " of " . $row['DivTotal'] . "</td>
<td width='150' align='center'><font face='calibri' size='-1'>" . $row['SexPlace'] . " of " . $row['SexTotal'] . "</td>";

if($row['Country'] == 'Usa')
{echo "<td width='200'><font face='calibri' size='-1'>" . $row['City'] . "</td>
<td width='75' align='left'><font face='calibri' size='-1'>" . $row['State'] . "</td>";}

else{echo "<td width='200'><font face='calibri' size='-1'>" . $row['Country'] . "</td>
<td width='75' align='left'><font face='calibri' size='-1'></td>";}


echo "
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['GunTime'] . "</td>
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['GunPace'] . "</td>
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['ChipTime'] . "</td>
</tr>
";
	 }

else{
echo "
<tr bgcolor='#eaeaea' onmouseover=\"this.style.backgroundColor='#d3d3d3'\" onmouseout=\"this.style.backgroundColor='#eaeaea'\">
<td width='50'><font face='calibri' size='-1'>" . $row['Place'] . "</td>
<td width='250'><font face='calibri' size='-1'><a href='ViewResultsMarathon.php?Bib=" . $row['BibNum'] . "&fname=$fname&lname=$lname&city=$city&state=$state&division=$division&sex=$sex&l=$l&h=$h' class='info'>" . $row['FirstName'] . " " . $row['LastName'] . "</a></td>
<td width='50' align='center'><font face='calibri' size='-1'>" . $row['Sex'] . "</td>
<td width='50' align='center'><font face='calibri' size='-1'>" . $row['Age'] . "</td>
<td width='100' align='left'><font face='calibri' size='-1'>" . $row['Division'] . "</td>
<td width='150' align='center'><font face='calibri' size='-1'>" . $row['DivPlace'] . " of " . $row['DivTotal'] . "</td>
<td width='150' align='center'><font face='calibri' size='-1'>" . $row['SexPlace'] . " of " . $row['SexTotal'] . "</td>";

if($row['Country'] == 'Usa')
{echo "<td width='200'><font face='calibri' size='-1'>" . $row['City'] . "</td>
<td width='75' align='left'><font face='calibri' size='-1'>" . $row['State'] . "</td>";}

else{echo "<td width='200'><font face='calibri' size='-1'>" . $row['Country'] . "</td>
<td width='75' align='left'><font face='calibri' size='-1'></td>";}


echo "
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['GunTime'] . "</td>
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['GunPace'] . "</td>
<td width='75' align='center'><font face='calibri' size='-1'>" . $row['ChipTime'] . "</td>
</tr>
";
	 }


  }
  
  
echo "
<tr>
	<td colspan='12'><br></td>
</tr>

<tr>
	<td colspan='6'><font face='calibri'><b>$num_rows Results Found</b></font></td>";
	
	
	
if($l == '0' & $num_rows > $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><b>Current Displaying $DispL-$DispH</b> | <a href='SearchResults10k-view.php?l=$LinkLow&h=$LinkHigh' class='info'>Next 100</a></font></td>";		
	}
elseif($l == '0' & $num_rows < $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><b>Current Displaying $DispL-$DispH</b></font></td>";
	}
elseif($l > '0' & $num_rows > $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><a href='SearchResultsMarathon-view.php?l=$PrevLinkLow&h=$PrevLinkHigh' class='info'>Previous 100</a> | <b>Current Displaying $DispL-$DispH</b> | <a href='SearchResultsMarathon-view.php?l=$LinkLow&h=$LinkHigh' class='info'>Next 100</a></font></td>";
	}	
elseif($num_rows < $h)
	{
echo "<td colspan='6' align='right'><font face='calibri'><a href='SearchResultsMarathon-view.php?l=$PrevLinkLow&h=$PrevLinkHigh' class='info'>Previous 100</a> | <b>Current Displaying $DispL-$DispH</b></font></td>";
	}		
	
	
	
echo "</tr>";  
  
?>
</table>

</td>





</table>









</td>
</tr>
</table>






















 
                    </td>
                </tr>
           </table>
							





<br /><br /><br />





		</td>
	</tr>
</table>





<table width='100%' border="0" cellspacing="0" cellpadding="0" align="center" class='bottom'>
	<tr>
    	<td width='100%'>
        
        	<table width='1000' align='center' class='bottominside'>
            	<tr>
            		<td width='50%' align='left'>
                    <font face='calibri' color='#b1b1b1'>Flash Results, Inc.</font>
            		</td>
             		<td width='50%' align='right'>
                    <img src='ipico.jpg' />&nbsp;&nbsp;<img src='lynx.jpg' />
            		</td>
            	</tr>


            </table>
        
        
        </td>
    </tr>

</table>

</body>
</html>
