+ 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 ?
2 Answers
+ 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â />;
}
+ 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