Jump to content

Help needed to change font color based on the value from the database in php


sankarkarthikeyan
 Share

Recommended Posts

Hi php freaks i am new to php  im doin a small project to handle tickets created by customers now i want to change the font color based on the status for

 

example:

 

ID                +                    Name                  +                          Product              +                  Status

------------------------------------------------------------------------------------------------------------------------------------

1111            +                  abcdef                  +                      bat                        +            processing

----------------+--------------------------------------+------------------------------------------+------------------------------

 

i can connect to database and fetch it the only place i need help is changing the any help would be very helpful

thanks in advance

 

 

Link to comment
Share on other sites

well what criteria are you using for deciding what color to use? Whatever it is, changing to font color is simple enough. You can change the font color of an html element by using the color style as part of the style html tag attribute. So for example, if I wanted to change the color of a p tag to yellow or something, I would write

<p style="color:yellow">some text blah blah</p>

 

I don't know how your html is set up, or what criteria the database information must meet to be a certain color, but the above may get you started. If you could post a few more details I can help further

Link to comment
Share on other sites

This is my HTML Coding thanks for your help people


if ($result) { 


echo '<table id="ticket">
<tr>
<th align="left"><b>Ticket No:</b></th>
<th align="left"><b>Name:</b></th>
<th align="left"><b>Issue:</b></th>
<th align="left"><b>Status:</b></th>
<th align="left"><b>view</b></th></tr>';



while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['id'] . '</td>
<td align="left">' . $row['name'] . '</td>
<td align="left">' . $row['product'] . '</td>
<td align="left">' . $row['status'] . '</td>
<td align="left"><a href="completeview.php?id=' . $row['id'] . '">View</a></td></tr>';
}

} else {
echo "Oops! No data found";
}
echo '</table>';

status:

Queued       :Red
Processing   :Amber
Packed         :Pale green
Shipped        : Green
Returned      : Grey

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.