+ 3

Fetch number of Stars from the sql database and show them in a webpage using php.

Not only the number of starts but also show the designed stars. Exactly like ratings. Anyone ?

31st Jan 2018, 8:01 PM
Sujoy Kumar Hens
Sujoy Kumar Hens - avatar
2 Réponses
+ 2
Well there’s alot of variations. $query = $db->query(”SELECT raiting FROM database”) $row = $query->fetch(); echo $row[”raiting”]; for($a = 0; $a < $row[”raiting”]; $a++) { echo ”<img src=’star.png’ />; }
31st Jan 2018, 9:41 PM
Toni Isotalo
Toni Isotalo - avatar
+ 3
Well, you can create function which will create stars for example: function showStars($a){ for($i=0; $i<$a; $i++){ echo "<img src='star.png' />"; } } And you need to call function during getting rows from database
31st Jan 2018, 9:36 PM
ThreeG
ThreeG - avatar