John Harbert
John Harbert

Reputation: 197

I need to assign a unqiue class to a PHP MYSQL table's TR

How can I assign a class id that is unique for all the <tr> The id's need to stay stay even when I refresh as I will be using them to style the table.

Here is the code I am using:

while($row = mysql_fetch_array($result2))
  {
echo "<tr id='centered' class='";  echo "'";   
echo "<td>" . $row['Year_9'] . "</td>";
echo "<td>" . $row['Year_8'] . "</td>";
echo "<td>" . $row['Year_7'] . "</td>";
echo "<td>" . $row['Year_6'] . "</td>";
echo "<td>" . $row['Year_5'] . "</td>";
echo "<td>" . $row['Year_4'] . "</td>";
echo "<td>" . $row['Year_3'] . "</td>";
echo "<td>" . $row['Year_2'] . "</td>";
echo "<td>" . $row['Year_1'] . "</td>";
echo "<td>" . $row['Year_0'] . "</td>";

Upvotes: 1

Views: 56

Answers (1)

Kermit
Kermit

Reputation: 34053

Perhaps use a counter with a multi-valued class?

$i = 1;

while($row = mysql_fetch_array($result2))
{
    $secondClass = 'abc' + $i;

    echo "<tr id='centered' class='firstClass $secondClass'>";
    ...
    $i++;
}

Upvotes: 2

Related Questions