Jump to content

League Table - a little help please...


Mr Chris

Recommended Posts

Hi Guys,

 

Wonder if anyone could kindly help me.

 

I have created a league table called out from a MYSQL database, which works fab:

 

http://www.sloughtownfc.net/new_design/table.php

 

However I want to do add three small things on this if possible:

 

1) Highlight my teams name automatically accross all it's cells to become a background of yellow (nomatter where we are in the table).  My team is Slough Town.

 

2) Highlight the top teams cells all green

 

3) Produce a 'smaller' version of the table like the one on this page:  http://www.harrowboro.com/

 

Where there are two teams above my team Slough Town and two below... Unless we are top and then it would still show my team then four teams below.

 

Here's my code:

 

<?php
// Get the data from the league table
$databaseInfo = mysql_query("SELECT
th.team_name AS the_team, r.table_id, r.team_id, r.played, r.team_wins, r.team_losses, r.team_draws, r.team_gf, r.team_ga, r.team_points_total, th.team_id
FROM league_table r
INNER JOIN teams th ON r.team_id = th.team_id
ORDER BY r.team_points_total DESC , r.team_gf - r.team_ga, r.table_id ASC") or die(mysql_error());
$bg = '#eeeeee';
?>
<table width="100%" class="tbl_stats">
          <tr> 
            <th>Pos.</th>
            <th>Team</th>
            <th>Played</th>
            <th>Won</th>
            <th>Drawn</th>
            <th>Lost</th>
            <th>GF</th>
            <th>GA</th>
            <th>Points</th>
          </tr>
          <?php 
	  $n=1;
	  while ($databaseArray = mysql_fetch_array($databaseInfo)){
	  // Set the BG
          $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
	  ?>
          <tr bgcolor="#FFFFFF"> 
	    <td bgcolor="<?php echo $bg; ?>"><?php echo $n; ?></td>
		<td bgcolor="<?php echo $bg; ?>"><a href='index.php?team_id=<?php echo $databaseArray['team_id']; ?>' class='link_text'><?php echo $databaseArray['the_team']; ?></a></td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['played']?></td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_wins']?>
            </td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_draws']?> 
            </td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_losses']?></td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_gf']?></td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_ga']?></td>
            <td bgcolor="<?php echo $bg; ?>"><?php echo $databaseArray['team_points_total']?></td>
          </tr>
	  <? $n++; } ?>
</table> 

 

Many Thanks

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/73932-league-table-a-little-help-please/
Share on other sites

If you put you table into php you could use "if"

like:-

 

$list = "<table border=\"0\" >";
	$list .= "<tr>";
	$list .= "<th>Team</th>";
	$list .= "<th>Played</th>";
	$list .= "</tr>";

while ( $row = mysql_fetch_array( $rs ) )
if ( $row["team_id"] = myteam)
{
	$list .= "<tr>";
	$list .= "<td><font color=\"red\">".$row["team_id"]." - ".$row["the_team"]."</font></td>";
	$list .= "<td>".$row["played"]."</td>";		
	}
else
{
	$list .= "<tr>";
	$list .= "<td>".$row["team_id"]." - ".$row["the_team"]."</td>";
	$list .= "<td>".$row["played"]."</td>";		
	$list .= "</tr>";
	}
$list .="</table>";

echo ($list);

 

to get you going

 

istead of changing font you could change the propeties of the row etc

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.