0

i tried. but it not success full.. please give me solution..

php code

<?php
function getReviews($con){
        $sql = "SELECT * FROM review";
        $result = mysql_query($sql,$con);
        while ($row = mysql_fetch_array($result)) {
            echo "<div class=' col-md-12 comment-box'>";
            echo "<div class='left-comm col-md-2'>";
            echo "<img class='img-responsive' src='images/article/avatar3.png'>";
            echo "</div>";
            echo "<div class='right-comm col-md-6'>";
            echo "<p class='user-name'>".$row['email']."</p>";
            echo for ($i=0; $i <$row['rating'] ; $i++) { 
        echo "*";
    }"<br>";
            echo $row['review']."<br>";
            echo "</div>";
            echo "</div><br>";
?>

i want to display rate value using stars.in this function.

  • Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – icecub Aug 14 '17 at 03:40
  • If it's not doing what you want it to do, what is it doing? Are you getting any error messages? – Nick Coons Aug 14 '17 at 03:43

1 Answers1

1

Change:

  echo for ($i=0; $i <$row['rating'] ; $i++) { 
        echo "*";
    }"<br>";

to:

for ($i=0; $i <$row['rating'] ; $i++) { 
    echo "*";
}
echo "<br />";
Amit Joshi
  • 1,334
  • 1
  • 8
  • 10