Fetch number of Stars from the sql database and show them in a webpage using php. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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