Historic NCAA College Basketball Rankings


[insert_php]
include(‘db/dbmysqli.php’);
include_once ‘db/common.php’;echo ‘




‘;
$wk=mysqli_real_escape_string($link,$_GET[‘week’]);
$yr=mysqli_real_escape_string($link,$_GET[‘yr’]);

if(!isset($_GET[‘week’])){
$sql = “SELECT distinct (substring(Date,1,4)) as year FROM NCAA_Basketball ORDER BY year DESC”;
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){

while($row = mysqli_fetch_array($result)){
$year=$row[‘year’];

echo ‘

‘; echo $year; echo ‘

‘;

$sql2 = “SELECT week, substring(Date,1,4) as year FROM NCAA_Basketball WHERE substring(Date,1,4) = ‘$year’ group by week ORDER BY week ASC”;

$result2=mysqli_query($link, $sql2);
while($row2 = mysqli_fetch_array($result2)){

$week=$row2[‘week’];

echo ‘

‘;
}
}

echo ‘

‘;
}
}
}

else{
echo ‘

‘;

$sql = “SELECT * FROM NCAA_Basketball where week =’$wk’ and substr(date,1,4)=’$yr’ ORDER BY `Total Rank` ASC”;

if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
$getID = mysqli_fetch_assoc($result);

$week = $getID[‘week’];
mysqli_data_seek($result, 0);

echo ‘

Week ‘; echo $week;echo ‘ Rankings:

‘;

mysqli_data_seek($result, 0);
while($row = mysqli_fetch_array($result)){

$f1=$row[‘Total Rank’];
$f2=$row[‘Team’];
$f3=$row[‘Record’];
$f4=$row[‘Total Rating’];
$f5=$row[‘Last Week’];
$f6=$row[‘Difference’];
$f7=$row[‘Win Rating’];
$f8=$row[‘Win Rank’];
$f9=$row[‘Points Rating’];
$f10=$row[‘Points Rank’];

$f2=utf8_encode($f2);

echo ‘

‘;
}
echo “

Overall Rank Team Record Overall Rating Last Week Difference Win Rating Win Rank Points Rating Points Rank
‘; echo $f1; echo ‘ ‘; echo $f2; echo ‘ ‘; echo $f3; echo ‘ ‘; echo $f4; echo ‘ ‘; echo $f5; echo ‘ ‘; echo $f6; echo ‘ ‘; echo $f7; echo ‘ ‘; echo $f8; echo ‘ ‘; echo $f9; echo ‘ ‘; echo $f10; echo ‘

“;
// Close result set
mysqli_free_result($result);
mysqli_free_result($result2);
}
else{
echo “No records matching your query were found.”;
}
} else{
echo “ERROR: Could not execute $sql. ” . mysqli_error($link);
}}

[/insert_php]