Jump to content

Recommended Posts

Hi,
I need help getting a php mysql 5 star rating system on my website. I have a table column voting script that works, but the results end up with colorful bars and that isn't visitor appreciated ;) I was wondering if you can help me get a 5 star rating system where I can have it very simple. Just the starts and a click and poof! the average score is right there, and no wacky colorful bars. Furthermore, I was hoping if you can integrate it as PHP with Mysql, since that would be the most efficient way to do it now. Lastly I would like for my homepage and the sidebars to be able to connect to the MySql data and arrange the top voted content first. A lot like youtube or those other websites that have the pictures dynamically changed by itself, - depending on the final rating. Any help are suggestions would be greatly appreciated thanks!

- TheFilmGod
Link to comment
https://forums.phpfreaks.com/topic/31632-php-mysql-5-star-rating-system-and/
Share on other sites

here is a easy example as the tutoral has some fixing to be done but the concept is the same all you do is add the stars to a folder in this example it a folder called stars then you connect to the database then the corresponding database number from a table will echo the correct stars good luck.

[code]

<?php session_start();

$db=mysql_connect("localhost","name","password");
mysql_select_db("what_ever",$db);

$query="select * from users_info_table where id='$id'";
$result=mysql_query($query);

while($record=mysql_fetch_assoc($result)){

$num=$record['number'];

if($num=='1'){

$stars="<img src='stars/stars1.png'></img>";

}elseif

($num=='2'){

$stars="<img src='stars/stars2.png'></img>";

}elseif

($num=='3'){

$stars="<img src='stars/stars3.png'></img>";

}elseif

($num=='4'){

$stars="<img src='stars/stars4.png'></img>";

}elseif

($num=='5'){

$stars="<img src='stars/stars5.png'></img>";
}

echo $stars;

}

?>

[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.