Jump to content

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


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

 

 

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

You could also do something like:

 

<p class="<?php echo $row['status']; ?>">some text blah blah</p>

 

Then in stylesheet do:

.processing {color: gray}
.backordered {color: red}
.shipped {color: green}
/*
etc...
*/

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.