Fetch number of Stars from the sql database and show them in a webpage using php. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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 Antworten
+ 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