sankarkarthikeyan Posted September 29, 2011 Share Posted September 29, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248124-help-needed-to-change-font-color-based-on-the-value-from-the-database-in-php/ Share on other sites More sharing options...
mikesta707 Posted September 29, 2011 Share Posted September 29, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248124-help-needed-to-change-font-color-based-on-the-value-from-the-database-in-php/#findComment-1274116 Share on other sites More sharing options...
AbraCadaver Posted September 29, 2011 Share Posted September 29, 2011 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... */ Quote Link to comment https://forums.phpfreaks.com/topic/248124-help-needed-to-change-font-color-based-on-the-value-from-the-database-in-php/#findComment-1274119 Share on other sites More sharing options...
sankarkarthikeyan Posted September 29, 2011 Author Share Posted September 29, 2011 Thanks brother let me try this and get back to you Quote Link to comment https://forums.phpfreaks.com/topic/248124-help-needed-to-change-font-color-based-on-the-value-from-the-database-in-php/#findComment-1274140 Share on other sites More sharing options...
sankarkarthikeyan Posted September 29, 2011 Author Share Posted September 29, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248124-help-needed-to-change-font-color-based-on-the-value-from-the-database-in-php/#findComment-1274146 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.