There is a field with user comments that left feedback to the product; in the comments, in addition to the text, there is a number from 1 to 5 stored in the database. A question how to deduce this number by a cycle? Those. I want to ensure that, depending on the number, the required number of stars is drawn: the number 1 - 1 star, 2 - 2, etc. How to achieve this?

  • how far will you go, what's the problem? - splash58
  • the problem is that I can put the estimates in a cycle through the condition (if the number is 1, then we put one star, etc.), but I need this to work without a condition, just a cycle. - Denis
  • can you get it from the base? how do you get all this? What does your cycle look like? - splash58
  • @Denis, you have a strange approach. Everything is done the other way around. There are 5 stars, and they are given a class, for example, active up to the number that a person has. And if you still want to do as you want. You will have a loop in the loop by asterisks. I do not see the problem to do this. Look on the Internet, a lot of scripts ranking, written in 5 lines, and with the stars - Vasily Barbashev
  • one
    simpler echo str_repeat('<span class="fa fa-star"></span>', $value); IMHO .... without any cycles - Alexey Shimansky

0