I get a $_GET array like this:
array(9) { [["C"]=> array(1) { [0]=> string(24) "22234" } ["FB"]=> array(1) { [0]=> string(11) "7500" } ["SB"]=> array(1) { [0]=> string(0) "22234" } ["TB"]=> array(1) { [0]=> string(0) "" } ["SS"]=> array(1) { [0]=> string(0) "" } ["OF"]=> array(1) { [0]=> string(0) "" } ["DH"]=> array(1) { [0]=> string(0) "" } ["SP"]=> array(1) { [0]=> string(0) "" } ["RP"]=> array(1) { [0]=> string(0) "" } }
I need to be able to loop through all the positions in the array and find the values (Id's)...
...then for each ID I want to run a db query to populate the results....
...and finally I want to be able to compare each result set. For example I want to be able to compare the number of games played for each player_id in the array?
Make sense?
This is what I have so far:
You can see it in action here
$get_array = array(C,FB,SB,TB,SS,OF,DH,SP,RP);
foreach ($get_array as $pos)
{
if (empty($_GET[$pos][0]))
{
$cct == "0";
}
else
{
$cct = count(explode(',', $_GET[$pos][0]));
$player = explode(',', $_GET[$pos][0]);
$sum += $cct;
for($i = 0; $i < count($player); $i++)
{
$sql = "SELECT * FROM mlbplayers p, mlbteams t, mlbpositions pos, mlbplayer_positions pp, mlbhstats hs
WHERE p.cbs_id=".$player[$i]."
AND pos.position_id = pp.position_id
AND pp.cbs_id = p.cbs_id
AND hs.cbs_id = p.cbs_id
AND p.mlbteam_id=t.mlbteam_id
GROUP by p.cbs_id";
$result = mysql_query($sql) or die (mysql_error() . ": $sql");
while ($row = mysql_fetch_assoc($result))
{
$lname = $row["lname"];
$fname = $row["fname"];
$mlbteam_id = $row["mlbteam_id"];
$picture_loc = $row["picture_loc"];
$position_id = $row["position_id"];
$mlbteam_city = $row["mlbteam_city"];
$mlbteam_name = $row["mlbteam_name"];
$mlbteam_abbv = $row["mlbteam_abbv"];
$hw = $row["hw"];
$college = $row["college"];
$dob = $row["dob"];
$bt = $row["bt"];
$birthplace = $row["birthplace"];
$salary = $row["salary"];
$g = $row["g"];
$ab = $row["ab"];
$h = $row["h"];
$dbl = $row["dbl"];
$trp = $row["trp"];
$hr = $row["hr"];
$rbi = $row["rbi"];
$r = $row["r"];
$tb = $row["tb"];
$bb = $row["bb"];
$k = $row["k"];
$sb = $row["sb"];
$cs = $row["cs"];
$obp = $row["obp"];
$slg = $row["slg"];
$ops = $row["ops"];
$ba = $row["ba"];
$pic_loc = $row["picture_loc"];
$injury = $row["injury"];
$injury_note = $row["injury_note"];
$singles = ($h - ($dbl + trp));
$fpts = (($hr * 4) + ($rbi * 1) + ($r * 1) + ($sb * 2) + ($dbl * 2) + ($trp * 3) + ($singles * 1));
}
$pic_root = "mages/MLBRankings/images";
?>
<td valign="top">
<table>
<tr>
<td>
<table>
<?php
if ($pic_loc != 'NULL')
{
?>
<tr height="80" valign="bottom"><td><img src="<?php echo "$pic_root/$pic_loc" ?>" alt="" border="3"><td></tr>
<?php
}
elseif ($pic_loc = 'NULL')
{
?>
<tr height="80" valign="bottom"><td><img src="<?php echo "$pic_root/nopicavail.gif"?>" alt="" border="3"><td></tr>
<?php
}
?>
<tr height="35" valign="bottom"><td><?php echo "<strong><u>$fname $lname</u></strong>"; ?><td></tr>
<tr><td><?php echo "$mlbteam_city $mlbteam_name"; ?><td></tr>
<?php
if ($injury == 1)
{
?>
<tr valign="bottom"><td><img src="newinjury.jpg" title="<?php echo $injury_note; ?>" border="0"> Injured<td></tr>
<?php
}
else
{
?>
<tr valign="bottom"><td>Healthy<td></tr>
<?php
}
?>
<tr valign="bottom"><td><?php echo "$fpts"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$g"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$ab"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$h"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$dbl"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$trp"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$hr"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$rbi"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$r"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$tb"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$bb"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$k"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$sb"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$cs"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$obp"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$slg"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$ops"; ?><td></tr>
<tr valign="bottom"><td><?php echo "$ba"; ?><td></tr>
</table>
</td>
</tr>
</table>
</td>
<?php
}
}
}
?>
</tr>
</table>
</div>
I guess the problem is that everything is a string and I need them in an array so I can make the comparisons