Preview:
Live demo: http://garryone.trei.ro/tests/voting.php
Source:
PHP Code:
<?php
function get_rating($number) {
if(is_numeric($number)) {
if($number <= 10 ) {
for($i=1;$i<=$number;$i++) {
echo '<img src="http://i.imgur.com/SdT8y.png" width="20px"/>';
}
if(strpos($number,".") && substr($number,2,1) != 0) {
if(substr($number,2,1) >2 && substr($number,2,1) <= 7) {
echo '<img src="http://i.imgur.com/kl5R2.png" height="19px" />';
}
if(substr($number,2,1) > 7) {
echo '<img src="http://i.imgur.com/SdT8y.png" width="20px"/>';
}
}
}
if($number > 10) {
echo 'Value must be up to 10.';
}
}
if(!is_numeric($number)) {
echo 'Value must be numeric.';
}
}
if(isset($_POST['submit'])) {
echo get_rating($_POST['text']);
}
?>
<form action="" method="post">
<input type="text" name="text" />
<input type="submit" name="submit" />
</form>