php - display number as image in sql -


i'm designing website neighbor potential restaurant wants open. need create page testimonials/review. i'd code number of stars in sql, i'm not sure how it.

essentially i'm looking way determine integer of ratings field (1-5) , each number, display star image.

so:

if rating = 1, display star.png once if rating = 2, display star.png twice ... if rating = 5, display star.png 5 times 

i'm not sure how write code so.

the website being written in php , css. i'd avoid jquery, javascript, .net, , forth, i'm not familiar them , 1 keeping site date.

here's i've got far, it's not working right, , syntax error:

$result = mysqli_query($con,"select * reviews");    while($row = mysqli_fetch_array($result))    {     if (rating = "1"()){     echo '<img src="star.png">' . } else if (rating = "2"()){     echo '<img src="star.png"><img src="images/star.png">' . } else if (rating = "3"()){     echo '<img src="star.png">star.png"><img src="images/star.png">' . }     else if (rating = "4"()){     echo '<img src="star.png"><img src="images/star.png">star.png"><img src="images/star.png">' . } else      echo '<img src="star.png"><img src="images/star.png">star.png"><img src="images/star.png"><img src="images/star.png">' . "<br/> <b>" .  $row['name'] .  "</b> <em>" .  $row['city'] . $row['state'] . $row['country'] . "</em><br/>" .  $row['review'] . "<br/> <hr> <br/>"   } ?> 

use select statement ratings place database.

store result in php variable (lets call $rating)

use php logic output number of stars (in html obviously) based on value of $rating.

hope helps :)


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -