View Full Version : Need Urgent Help

05-23-2011, 08:20 AM
Hi guys, please help if you can, in a bit of a pinch at the moment.

I have setup a basic CMS for a client, wherein she can upload products to a mysql DB, and then it spits them out on here product page.

Heres my problem:

With one portion of the product their is a swatch color option. I have check boxes setup for all the main colors. I got it to upload to the DB fine.


When I pull that data from the DB, for instance it might be

Red, Green, Blue

How can I make it so that rather than showing the word red it shows a picture of the swatch that I am referring to?

I have all of the swatches on the server I just need to figure out a way to make it happen.

Ive tried a variety of loops, exploded the array, just can't seem to figure it out.

Need help asap, thanks for reading.

If code helps

echo "<small>" . $data['colors'] . "</small><br />";

That echoes out all of the colors that she checked when uploading a file, could be just black, could be blue orange red green etc. (Comma separated).

I need to make it so that instead of showing up as black

It shows up as a picture of the black swatch.

05-23-2011, 09:46 AM
Please edit the subject, by following the directions at http://www.codingforums.com/postguide.htm

05-23-2011, 09:56 AM
An easy and quick way would be to add another column to the colours table with the swatch image src in and then when loading the colours you could just display the image using the src from the database.