Jump to content

Using php w/ mySQL for conditional CSS


GrippingGrain

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...