Jump to content

Using php w/ mySQL for conditional CSS


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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...