djs22
djs22

Reputation: 1156

Create an HTML Class in a PHP Document

I'm currently trying dynamically create an html table in PHP. Further, I want the first two lines to be a different color. The solution I see is to give them a class and then use css to color the lines.

if ($count<=2){
   echo "<tr> class='color'";
}else
   echo"<tr>";
//other code
echo"</tr>";

Problem is my code prints out the words "class='color'"

Does anyone know why this is happening? Thanks!

Upvotes: 0

Views: 103

Answers (1)

Scorchio
Scorchio

Reputation: 2871

Of course. What is this

echo "<tr> class='color'";

instead of

echo "<tr class='color'>";

?

No offense intended, but try checking the plain HTML code before turning it into something dynamic.

Upvotes: 4

Related Questions