I am showing statistics from my database, if the number is between 80 and 99 I want the label to be label-success, if the number is between 51 and 79 label-warning and if the number is between 0 and 50 label-danger.
Something like this:
$query = $db->query("SELECT * FROM stats");
foreach ($query as $row) {
$points = $row['points'];
$votes = $row['votes'];
$postclass = "";
foreach (range(0,50) as $row) {
$posclass = "danger";
}
foreach (range(51,79) as $row) {
$posclass = "warning";
}
foreach (range(80,99) as $row) {
$posclass = "success";
}
echo '
<span class="label label-'.$posclass.'" >'.$points.'</span>
<span class="label label-'.$posclass.'" >'.$votes.'</span>
';
}
Thanks!