How to decide the font color php according to the sql query

Asked By 10 points N/A Posted on -
qa-featured

Hi,

I am a student that learning web development.

I have a small online application.

In that the color of the same massage should he different from the SQL quarry the run.

I can’t figure out this myself.

Please help me with this.

Thank you.

SHARE
Answered By 10 points N/A #152513

How to decide the font color php according to the sql query

qa-featured

Hi,

You can do it by getting the value from the database and assigning it as a color to the element. Check the following code as an example:
<?php
 
$result = mysql_query("SELECT * FROM Colors");
 
echo "<table border='3'>
 
<tr>
 
<th>Colors</th>
</tr>";
while($row = mysql_fetch_array($result))
 
  {
  echo "<tr>";
 echo "<td style=’color:”. $row['Color'].“’>" . $row['Color'] . "</td>";
 
  echo "</tr>";
  }
echo "</table>";
 
?>
 
I hope this will helps you.
 
Thank you
 

Related Questions