Forum Moderators: coopster

Message Too Old, No Replies

Issues with pulling certain data per ID

         

goody2

10:49 pm on Jul 30, 2011 (gmt 0)

10+ Year Member



Again i am having trouble pulling certain data per id. Here is my code....


<?php
include 'connect.php';
?><?php



if ($type == Regular_Season)
{
$subset = playoffskaters10;
}
else
{
$subset = regularseasonskaters11;
}

$statspage = $_SERVER["SCRIPT_NAME"];
$condition = "Rookie = 1 AND Games >=1";
?>

<?php
include 'skatercontentrookies.php';
?>



That code leads to this code for the specific info that im looking for...

<?php
include 'connect.php';
?>

<?php

$teamidmap ['ANA'] = "2";
$teamidmap ['WPG'] = "3";
$teamidmap ['BOS'] = "4";
$teamidmap ['BUF'] = "5";
$teamidmap ['CGY'] = "6";
$teamidmap ['CAR'] = "7";
$teamidmap ['CHI'] = "8";
$teamidmap ['COL'] = "9";
$teamidmap ['CBJ'] = "10";
$teamidmap ['DAL'] = "11";
$teamidmap ['DET'] = "12";
$teamidmap ['EDM'] = "13";
$teamidmap ['FLA'] = "14";
$teamidmap ['LA'] = "15";
$teamidmap ['MIN'] = "16";
$teamidmap ['MTL'] = "17";
$teamidmap ['NSH'] = "26";
$teamidmap ['NJ'] = "19";
$teamidmap ['NYI'] = "20";
$teamidmap ['NYR'] = "21";
$teamidmap ['OTT'] = "22";
$teamidmap ['PHI'] = "23";
$teamidmap ['PHX'] = "24";
$teamidmap ['PIT'] = "25";
$teamidmap ['SJ'] = "32";
$teamidmap ['STL'] = "27";
$teamidmap ['TB'] = "28";
$teamidmap ['TOR'] = "29";
$teamidmap ['VAN'] = "30";
$teamidmap ['WSH'] = "31";

$statsfind = $_REQUEST["statsfind"];

$order = $_REQUEST["desc"];
// remove junk headers
mysql_query("DELETE FROM $subset WHERE id=1 ")
or die(mysql_error());


if ($statsfind != NULL)
$sortvar = $statsfind;
else
$sortvar = "Points";

if ($order == DESC)
{
$order = "ASC";
}
elseif ($order == ASC)
{
$order = "DESC";
}
else
{
$order = "DESC";
}

if ($type == Regular_Season)
{
$type = Playoffs;
}
elseif ($type == Playoffs)
{
$type = Regular_Season;
}


$teamid = $_GET["id"];
if (!is_numeric($teamid)){die();}

// default stats ordered by points
$data = mysql_query("SELECT * FROM $subset WHERE $condition and Games > 0 ORDER BY $sortvar $order LIMIT 0, 5 ")
or die(mysql_error());
Print "<table >";
if ($teamid != NULL)
Print "<th align=center width=10 bgcolor=#ebf0f6 >&nbsp;&nbsp;#&nbsp;&nbsp;</th>";
Print "<th align=align=left width=30 bgcolor=#ebf0f6 >Name</th>";
if ($teamid == NULL)
Print "<th align=center width=30 bgcolor=#ebf0f6 >Team</th>";
Print "<th align=center width=30 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=Games&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">GP</a>
<?php
Print "</th>";
Print "<th align=center width=20 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=Goals&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">G</a>
<?php
Print "</th>";
Print "<th align=centerht width=20 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=Assists&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">A</a>
<?php
Print "</th>";
Print "<th align=center width=20 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=Points&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">P</a>
<?php
Print "</th>";
Print "<th align=center width=20 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=PlusMinus&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">+/-</a>
<?php
Print "</th>";
Print "<th align=center width=20 bgcolor=#ebf0f6 >";
?>
<a href="<?php print $statspage ?>?statsfind=PIM&asc=<?php print $order ?>&id=<?php print $teamid ?>&type=<?php print $type ?>">PIM</a>


<?php


while($info = mysql_fetch_array( $data ))
{
$playergames = $info['Games'];
$playermin = $info['Min'];

$playeravgmingame = floor($playermin/$playergames);
$playeravgsecgame = sprintf ("%02d", ($playermin/$playergames - floor($playermin/$playergames))*60);

//Print "<tr bgcolor="#ffffff">";
Print "<tr>";

$playerid = $info['Instanceid'];
$teamabr = $info['Team'];
$playername1 = $info['First'];
$playername2 = $info['Last'];
$playername = $playername1." " . $playername2;
$playerdet = "playerdetail.php?playerid=";
$position = $info['Position'];


if ($teamid != NULL)
Print "<td align=center>" .$info['Jersey'] ."</td>";

Print "<td ALIGN=left width=200><a href='".$playerdet .$playerid ."&id=" .$teamidmap [$teamabr] ."'>" .$playername ."</a>, " .$position ."</td>";

if ($teamid == NULL)
Print "<td ALIGN=center>".$info['Team'] . " </td>";

Print "<td ALIGN=center>".$info['Games'] . " </td>";
Print "<td ALIGN=center>".$info['Goals'] . " </td>";
Print "<td ALIGN=center>".$info['Assists'] . " </td>";
Print "<td ALIGN=center>".$info['Points'] . " </td>";
Print "<td ALIGN=center>".$info['PlusMinus'] . " </td>";
Print "<td ALIGN=center>".$info['PIM'] . " </td>";


Print "</tr>";
}

Print "</table>";
?>



I get the info im looking for but i want to show the info per team not all teams...


Any help would be fantastic....

coopster

1:35 pm on Aug 31, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



At first glance I do not see where you are querying using the id in your WHERE clause. If you only want results for one identifier then you need to add that to your WHERE condition.