Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

How to use hex numbers stored in mysql database

Posted 28 Nov 2004 11:08:35
1
has voted
28 Nov 2004 11:08:35 Simon Wantling posted:
Hi,
I am tryinig to change the colours of a table cell using a hex value store in a mysql database. Is there anyway in dreamweaver that I can extract that value from the database and use it to set the background colour. I am hoping its similar to using a recordset as I'm getting pretty familiar which it now thanks to all the help on this forum !!
Many Thanks
Simon

Replies

Replied 28 Nov 2004 12:50:26
28 Nov 2004 12:50:26 Simon Martin replied:
In old html you would do something like this
<td bgcolor="#CC0066">
So if you've got your hex colour from the database in a recordset you would use that to dynamically populate the colour
<td bgcolor="<%=rsMyRecordSet("hex"">

Although you probably should consider using CSS to style the cells, which would mean you'd need to dynamically set the class for the cells based on the value in your recordset, using a CASE SELECT to determine which value to use. Much neater code if you go with this option, but also harder to implement if you've not done any conditional logic before

Live the life you love
Love the life you live

Simon

[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 28 Nov 2004 21:42:27
28 Nov 2004 21:42:27 Simon Wantling replied:
Thanks Simon,
I have managed to set up a series of checkboxes to represent the months of the year. When a relevent box is checked it is supposed to send a hex value toi my database. Unfortunately all that seem to appear in the database is either a Y or N to say whether the box has been checked and not the hex number. Any ideas? I added the checked value into dreamweaver properties, so I'm not sure whats going on here. I hope you use the hex value to determine a table cell colour.
Many Thanks
Simon
Replied 29 Nov 2004 12:56:27
29 Nov 2004 12:56:27 Simon Martin replied:
Hi Simon,

Checkboxes are boolean selections; yes or no, on or off, 1 or 0 and not really the right UI for what you are trying to do. So I think you should rethink the checkbox strategy, if you want to have mutually exclusive options (yes/no or jan/feb/mar/apr etc) then either use a radio group or a drop down menu; and of those the drop down menu will probably be the easiest to implement.
Set up a tblMonths in your DB and populate it with the months of the year and also give each a hex value (assuming each month only has 1 hex value associated with it) Then you can have a drop down menu populated with the names of the months, that selects the hex value associated with it.

There is a good article by Jakob Neilson about the correct use of checkboxes Vs Radio group buttons in his Alert Box that you might find useful,
www.useit.com/alertbox/20040927.html

Live the life you love
Love the life you live

Simon

[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]


Edited by - ganseki on 29 Nov 2004 13:39:30

Reply to this topic