/*************************************
Title: Changing category name color
Version: 2
Short description:
I have used thispost to add the category name to the table on the admin home page, and it works great.
My question is, how can I set a different color to a specific category name in the table?
I tried wrapping the category name with <font color="red">New category</font> but that just printed out the font tag as well.
Thanks.
*************************************/
(Here below you can write additional info, longer description and comments)
Changing category name color
Moderator: mkoch227
That's because HTML tags are encoded for security. Try using something like before printing the category name (assuming you have the category name stored in $newcategory['name'] variable).
Code: Select all
$newcategory['name'] = preg_replace('/<font color="(.+)">(.*)<\/font>/','<font color="$1">$2</font>',$newcategory['name']);
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post the exact code you use for printing the category name.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
This is the sql to fetch the category:
$sql = "SELECT * FROM `hesk_categories` WHERE `id`=$ticket[category] LIMIT 1";
$newresult = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$newcategory = hesk_dbFetchAssoc($newresult);
This is the print category name:
<td class="$color">$newcategory[name]</td>
thanks for your help.
$sql = "SELECT * FROM `hesk_categories` WHERE `id`=$ticket[category] LIMIT 1";
$newresult = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$newcategory = hesk_dbFetchAssoc($newresult);
This is the print category name:
<td class="$color">$newcategory[name]</td>
thanks for your help.
How about if you add something like
just below ? Change 'Your category' to the exact name of your category (case sensitive).
Code: Select all
if ($newcategory['name'] == 'Your category')
{
$newcategory['name'] = '<font color="red">'.$newcategory['name'].'</font>';
}
Code: Select all
$newcategory = hesk_dbFetchAssoc($newresult);
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools