GrippingGrain Posted February 14, 2012 Share Posted February 14, 2012 I'm currently trying to style list items (<li>'s) using information from a mysql table with php for a to-do style app. I want the <li> to be a certain color based on what a value particular item in my table under the table category "priority". I tried this which didn't work: <?php if ("SELECT * FROM `422`.`toDoList` WHERE `priority` = '1';") {$scolors = "#fecc15";} else if ("SELECT * FROM `422`.`toDoList` WHERE `priority` = '2';") {$scolors = "#99bd25";} else if ("SELECT * FROM `422`.`toDoList` WHERE `priority` = '3';") {$scolors = "#f37f19";}?> //and then in CSS this block to add the color:#output li {background-color: $colors;} I'm guessing the if statements are what don't work here, but I'm not sure... How would I go about using my mySQL table data to conditionally affect that background-color CSS attribute? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 14, 2012 Share Posted February 14, 2012 You need to tell PHP to print the value of that variable. background-color: <?php echo $colors; ?>; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.