View Full Version : echo mysql data
01-28-2012, 12:57 AM
I have 1 column named "style" in my db. In this column I use 2 values, "1" and "2". I wan't to SELECT * from db and echo rows that have value "1" in yellow background and rows that have value "2" in black background, all ORDER BY style DESC.
What should I use?
01-28-2012, 01:22 AM
A good start is to show us what coding you have tried thus far
01-28-2012, 03:14 AM
in the table (i'm assuming you are displaying the recs in a table as you have given very little detail) add the following into the row
background-color="<?php echo $thisStyle == 1 ? 'yellow' : 'black';?>"
the variable $thisStyle needs to be replaced with whatever you have available in the loop that holds the value
01-28-2012, 10:30 AM
thank you jmj for the answear.
And if I wan't to change more than the background... should I use SWITCH statement? Or what is the easiest way?
01-28-2012, 11:06 AM
if you wanted to change other parts of the styling depending on the result of either 2 options i'd suggest just use that same kind of statement for the different style options...
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.