How to arrange this php if-statement which outputs ratings (good, great, exxelent, etc.)?

Tags: php,css,if-statement

Problem :

I'm using php if-statements to add classes to divs that are related to rating:


.average .rating-result {
    color: #888; /* 0~1 votes */
.good .rating-result {
    color: #9a6e65; /* 2~3 votes */
.great .rating-result {
    color: #aa5443; /* 4~5 votes */
.excellent .rating-result {
    color: #bb3b22; /* 6~7 votes */
.brilliant .rating-result {
    color: #cc2200; /* 8~9 votes */


 <div class="topic-like-count<?php if ( $thumbs_number == 0 || 1 ) {
 echo " good"; } elseif ( $thumbs_number == 2 || 3 ) { echo " great"; }
 elseif ( $thumbs_number == 4 || 5 ) { echo " excellent"; } elseif (
 $thumbs_number > 6 || 7 ) { echo " brilliant"; } else { echo "
 average"; }?>"> h4><?php wp_gdsr_render_article_thumbs(); ?></h4>

OUTPUT example:

<div class="topic-like-count good">
<div style="display: none">UA:D [1.9.10_1130]</div>
<div class="thumblock ">
<span class="rating-result">4</span>
<div class="ratingtext ">
<div class="raterclear"></div>

I'm not sure how to organize the PHP part. Above I discribed the idea but that code doesn't work properly.

Does anyone have any suggestion to arrange these php if-statements?

Solution :

  <div class="topic-like-count
    switch ($thumbs_number) {
      case 0:
      case 1: echo ' good'; break;
      case 2:
      case 3: echo ' great'; break;
      case 4:
      case 5: echo ' excellent'; break;
      case 6:
      case 7: echo ' brilliant'; break;
      default: echo ' average'; break;
  <h4><?php wp_gdsr_render_article_thumbs(); ?></h4>

    CSS Howto..

    How to enlarge footer on mobile only?

    HTML/CSS - How to position my image to the right so that it can be aligned with my text on the left?

    How to select an element that must have more than one css class?

    why is .show() making the target div appear at top of page?

    how to show one element under the other one?

    How to make a picture responsive that is on wordpress custom post type through HTML/CSS

    How to animate a div to move from end to end infinitely

    How to horizontally align to “block” divs inside a div?

    How to remove the background in a slick carousel?

    How can I request a CSS attribut in HtmlUnit?

    How to align banner right in Internet Explorer 8

    How can I prevent a flex container from overflowing/underflowing?

    How to toggle visibility of 2 divs after clicking a mailto link?

    How can I limit Bootstrap column to a specific column's height?

    how would you set up the GUI for a web-based board game structure?

    How to use HTML/CSS to show images and titles inline?

    How to create desired form with css without using too many div tags?

    Showing play button and time on each image

    How to use scrollRevealJS alongside AnimateCSS?

    How can I code CSS to make Table like?

    How do I make a hover over only take up a portion of an image as seen on [closed]

    CSS how do I define the height between multiple label and textboxes elements

    How to remove scroll bar using overflow CSS HTML (Possible Positioning Conflict)

    How can a site Use Javascript and NOT display any structural HTML in the browser?

    How to change styling of a specific div onhover of another element when divs share an id

    How to specify BOTH max-width % and px [closed]

    How to lay down elements vertically from top to bottom, and then from right to left, using a clean HTML markup?

    How do I make these buttons stay activated after clicking on them?

    How to scale a .svg being the background in a div?

    Sub menu wont show when menu item hovered over (css html)