Jump to content
GarryOne

Script PHP rating

Recommended Posts

Posted

Preview:

svgZT.png

Demo: http://garryone.trei.ro/tests/voting.php

Source:

<?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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...