473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

RGB to HTML

Hi

Please help

I have this mysql table field with a RGB value like 120-10-200 and I
nead this php function to convert this value into html color
#??????

Thanks in advance

Feb 21 '08 #1
4 1952
On Thu, 21 Feb 2008 11:24:24 +0100, cj************@gmail.com
<cj************@gmail.comwrote:
Hi

Please help

I have this mysql table field with a RGB value like 120-10-200 and I
nead this php function to convert this value into html color
#??????
If you need in in css, it can perfectly handle rgb(123,123,123) values,
however, it's a simple matter of explode(), dechex() the items, and
implode() or concatenate.

--
Rik Wasmus
Feb 21 '08 #2
cj************@gmail.com wrote:
I have this mysql table field with a RGB value like 120-10-200 and I
nead this php function to convert this value into html color #??????
<?php
$rgb = '120-10-200';
list ($r, $g, $b) = explode('-', $rgb);
$hex = sprintf('#%02x%02x%02x', $r, $g, $b);
?>

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 22 days, 17:55.]

Bottled Water
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
Feb 21 '08 #3
..oO(Toby A Inkster)
>cj************@gmail.com wrote:
>I have this mysql table field with a RGB value like 120-10-200 and I
nead this php function to convert this value into html color #??????

<?php
$rgb = '120-10-200';
list ($r, $g, $b) = explode('-', $rgb);
$hex = sprintf('#%02x%02x%02x', $r, $g, $b);
?>
<?php
$rgb = '120-10-200';
$hex = vsprintf('#%02x%02x%02x', explode('-', $rgb));
?>

SCNR
Micha
Feb 21 '08 #4
On 21 Lut, 18:13, Michael Fesser <neti...@gmx.dewrote:
.oO(Toby A Inkster)
cjlopesmart...@gmail.com wrote:
I have this mysql table field with a RGB value like 120-10-200 and I
nead this php function to convert this value into html color #??????
<?php
$rgb = '120-10-200';
list ($r, $g, $b) = explode('-', $rgb);
$hex = sprintf('#%02x%02x%02x', $r, $g, $b);
?>

<?php
$rgb = '120-10-200';
$hex = vsprintf('#%02x%02x%02x', explode('-', $rgb));
?>
<?php $hex = vsprintf('#%02x%02x%02x', explode('-', '120-10-200')); ?>

:>
Feb 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
1
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML...
33
by: LRW | last post by:
http://gto.ie-studios.net/index.php When you view the above site in IE, if the 1st of the three product images is tall enough to push the cell down a couple of pixels, IE somehow doesn't show...
0
by: Boris Ammerlaan | last post by:
This notice is posted about every week. I'll endeavor to use the same subject line so that those of you who have seen it can kill-file the subject; additionally, Supersedes: headers are used to...
9
by: Patient Guy | last post by:
Taking the BODY element as an example, all of its style attributes ('alink', 'vlink', 'background', 'text', etc.) are deprecated in HTML 4.01, a fact noted in the DOM Level 2 HTML specification. ...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
6
by: Guy Macon | last post by:
cwdjrxyz wrote: HTML 5 has solved the above probem. See the following web page: HTML 5, one vocabulary, two serializations http://www.w3.org/QA/2008/01/html5-is-html-and-xml.html
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.