Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-28-2005, 09:34 PM php help
Average Talker

Posts: 18
Location: Email
Trades: 0
I working on a football site. I'm trying to display yearly stat leaders, broken down by week. This works perfectly if I only have one year worth of stats in the database..If I have more than one, thats were I run into trouble. Basically this is what I want to do.

Display the years in db, like this:

Code:
2003 | 2004 | 2005
then when a user selects a year, the weeks associated with that year will be shown like this:

Code:
1  | 2 | 3 | 4 | etc....
I think I'm getting close, but I have this problem..all the years are shown, but so are all of the weeks at one time...

see here:

http://www.fantasyfootballresearch.c...ingleaders.php

Here is my code so far...please help!!

PHP Code:
  $query = "select week, year from playerstats
  group by year";
  $result = mysql_query($query);
  while($year = mysql_fetch_array($result)){
    // build html for links

$yrlinks_html .= "<a href='/football/passingleaders.php?year=" . $year["year"] . "'>" . $year["year"] . ""."</a> | ";
     }


 // select weeks first, and make links

  $query = "select week, year from playerstats group by week, year";
  $result = mysql_query($query);
 while (list ($week, $year) = mysql_fetch_array($result)){
    // build html for links

$links_html .= "<a href='/football/passingleaders.php?year=" . $year . ""."&week=" .
$week["week"] . "'>" . $week["week"] . ""."</a> | ";
     }

  // now select for this specific week/year....hopefully
  // print links here

echo "<table align=\"center\">";
echo "<tr>";
echo "<td>Select a Year: </td>";
echo "<td align=\"center\">$yrlinks_html</td>";
echo "<td>Select a Week: </td>";
echo "<td align=\"center\">$links_html</td>";
echo "</tr> </table>";

  // now select for this selected year/specific week

 $week = $_GET["week"];
if(empty($week))
  $week = 12;

 $year = $_GET["year"];
if(empty($year))
  $year = 2005;


print "<h2 align=\"center\">Year: " . $year . "</h2>";
print "<h2 align=\"center\">Week " . $week . ": Quarterback Leaders</h2>";
?>
<p class="divtest" align="center"> Position: <a

href="http://www.fantasyfootballresearch.com/football/passingleaders.php">QB</a> | <a

href="http://www.fantasyfootballresearch.com/football/rushingleaders.php">RB</a> | <a

href="http://www.fantasyfootballresearch.com/football/receivingleaders.php">WR</a> | <a

href="http://www.fantasyfootballresearch.com/football/tereceivingleaders.php">TE</a> | <a

href="http://www.fantasyfootballresearch.com/football/kickingleaders.php">K</a> | <a

href="http://www.fantasyfootballresearch.com/football/defensiveleaders.php">DEF</a></p>

<p align="center"><a href="http://www.fantasyfootballresearch.com/football/seasonQBleaders.php">View Season Leaders</a></p>

<?php

 $query 
"SELECT lname, fname, rush_att, rush_yd, rush_td, pass_att, pass_cmp, pass_td, pass_yd, playerstats.int, fmbl_lost,
twopt, playerstats.player_id, players.nflteam_id, nflteam_abbv, players.position_id
  FROM playerstats, players, nflteams, positions
  WHERE playerstats.player_id = players.player_id
  AND players.position_id = positions.position_id
  AND players.position_id = 1
  AND nflteams.nflteam_id = players.nflteam_id
  AND nflteam_abbv = nflteams.nflteam_abbv
  AND week = '" 
$week "'
  ORDER by pass_yd DESC
  LIMIT 29"
;

   
$result mysql_query($query);

   
//checking output

   
$num_results mysql_num_rows($result) or die(mysql_error());
   if (
$num_results == 0)
   {
      echo 
"No Results Found";
   }
   else
   {

     
?>
<p align="left" class="small">* Click on headers to sort stats.</p>
<table align="center" width="75%" border="1" cellpadding="2" cellspacing="0">
    <TR>
           <TD width="38%" VALIGN="middle" BGCOLOR="#AB0507">&nbsp;</TD>
           <TD width="34%" align="center" VALIGN="middle" BGCOLOR="#AB0507"><font

color="#FFFFFF"><b>PASSING</b></font></TD>
        <TD width="12%" align="center" BGCOLOR="#AB0507"><font color="#FFFFFF"><B>TO</B></font></TD>
        <TD width="16%" align="center" BGCOLOR="#AB0507"><font color="#FFFFFF"><B>Rushing</B></font></TD>
    </TR></table>
<table bgcolor="#CCCCCC" class="sortable" id="passing" align="center" width="75%" border="1" cellpadding="2" cellspacing="0">
    <tr>
         <th><b><u>Player</u></b></th>
         <th><b><u>Team</b></u></th>
         <th><b><u>FFR Pts</b></u></th>
         <th><b><u>Cmp</b></u></th>
         <th><b><u>Att</b></u></th>
         <th><b><u>Cmp%</b></u></th>
         <th><b><u>YD</b></u></th>
         <th><b><u>TD</b></u></th>
         <th><b><u>Int</b></u></th>
         <th><b><u>Fum</b></u></th>
         <th><b><u>Att</b></u></th>
         <th><b><u>YD</b></u></th>
         <th><b><u>TD</b></u></th>
    </tr>

<?php
 $i 
0;
      while(
$row MySQL_fetch_array($result)) {

        
$lname $row['lname'];
        
$fname $row['fname'];
        
$rush_yd $row['rush_yd'];
        
$rush_att $row['rush_att'];
        
$rush_td $row['rush_td'];
        
$pass_att $row['pass_att'];
        
$pass_yd $row['pass_yd'];
        
$pass_td $row['pass_td'];
        
$pass_cmp $row['pass_cmp'];
        
$cmppct $pass_cmp $pass_att 100;
        
$cmppctround ROUND($cmppct1);
        
$int $row['int'];
    
$twopt $row['twopoint'];
        
$week $row['week'];
    
$player_id $row['player_id'];
    
$nflteamabbv $row['nflteam_abbv'];
    
$fumble $row['fmbl_lost'];
    
$points = (($pass_yd 0.034) + ($pass_td 6) + (twopt 2) + ($int * -2) + ($fumble * -2) + ($rush_yd 0.067) +
(
$rush_td 6));
    
$pointsround ROUND($points1);


echo 
" <tr><td><a href='/football/players.php?player_id=" $player_id "'> ".$fname."
"
.$lname."</td>";
echo 
"<td>".$nflteamabbv."</td>";
echo 
"<td align=\"center\">".$pointsround."</td>";
echo 
"<td align=\"center\">".$pass_cmp."</td>";
echo 
"<td align=\"center\">".$pass_att."</td>";
echo 
"<td align=\"center\">".$cmppctround."</td>";
echo 
"<td align=\"center\">".$pass_yd."</td>";
echo 
"<td align=\"center\">".$pass_td."</td>";
echo 
"<td align=\"center\">".$int."</td>";
echo 
"<td align=\"center\">".$fumble."</td>";
echo 
"<td align=\"center\">".$rush_att."</td>";
echo 
"<td align=\"center\">".$rush_yd."</td>";
echo 
"<td align=\"center\">".$rush_td."</td>";

            }
   }

  
?>


</table>


<div align="center"><?php require($DOC_ROOT "/lib/footer.php"); ?></div>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
esiason14 is offline
Reply With Quote
View Public Profile Visit esiason14's homepage!
 
 
Register now for full access!
Reply     « Reply to php help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25929 seconds with 12 queries