php - How to apply style in an echo'ed ? -



php - How to apply style in an echo'ed <td>? -

this php code:

$query="select name, surname, address employee"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { echo '<tr>'; foreach($row $field) { echo '<td class="element">' . htmlspecialchars($field) . '</td>'; } echo '</tr>';

and css:

.element{ color:red; }

but fields displayed in html page aren't red. why doesn't work?

i tried

echo "<td class='element'>" . htmlspecialchars($field) . "</td>";

and

echo '<td class=\"element\">' . htmlspecialchars($field) . "</td>";

but no success.

i suggest specify element in css.

td.element{ color:red; }

also it's thought give "tr" id "tr id="mytr"...

#mytr td.element{ color:red; }

php html css

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -