Page 1 of 1

Highlighting a row in a table with many rows

Posted: Wed Apr 14, 2010 8:26 am
by ThePHPApprentice
Hi,

Newbie here.

I am trying to hlighlight a row in a table with many rows using a css class.
As the user click on a team link (left), the stats related to that team bolden (the css class applies). I know I need an if statement of some kind but where in my code and how to set it up...

Any hints? I have created a variable called $sel_stat which contains $_GET values (team_id) for each team.
Here is my code and a picture of the table which is attached.

Code: Select all


<tr>
    	<?php
        	//3. Perform Database Query
			$standing_stat = mysql_query("SELECT * FROM teams", $connection);
			if (!$standing_stat) {
				die("Database connection failed: " . mysql_error());
			}
			//4. Use Returned Data
			echo  "<br />";
			while ($stat = mysql_fetch_array($standing_stat)) {
				echo "<td><a href=\"standings.php?stat=" . urlencode($stat["team_id"]) .
				"\">{$stat["team_name"]}</a></td>";
				
				echo "<td>" . $stat["rank"] . "</td>";
				echo "<td>" . $stat["gp"] . "</td>";
				echo "<td>" . $stat["wins"] . "</td>";
				echo "<td>" . $stat["losses"] . "</td>";
				echo "<td>" . $stat["ties"] . "</td>";
				echo "<td>" . $stat["points"] . "</td>";
				echo "<td>" . $stat["goals_for"] . "</td>";
				echo "<td>" . $stat["goals_against"] . "</td>";
				echo "<td>" . $stat["streak"] . "</td>" .
				"<tr></tr>";
			}
			
		?>
  
    
    
    </tr>



Re: Highlighting a row in a table with many rows

Posted: Wed Apr 14, 2010 9:54 am
by pickle
You need a Javascript solution, so I've moved this to the Javascript forum.

You want to add some Javascript so that whenever the team name is clicked, the relevant row gets a class added.