Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-08-2008, 07:15 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming Professional
 
Join Date: Feb 2008
Posts: 343
Rep Power: 4
phpforfun is on a distinguished road
Default help on a php 5 star rating system

Hey guys, sooo Im almost done with my site, all I need is to:
#1 finish the administrative side, (havent even started)
#2 finish the testimony/review, (the part where you rate the host)
#3 forums
#4 Random stuff (terms of service, about, support, help, etc)

So.. anywhere from a week to a month.


ALRIGHT!
Im extremely stuck on #2, I usually dont download and edit PHP scripts, just JS, but I had no idea where to start, other than maybe adding 1 to the number of times rated, then add the rating # to a field, so I could use some PHP math to get the average, and output that with a star image..

So I downloaded this script.
<see attached>

What im having an issue with is getting it to forget about the IP, forget about recording the raters data to a file, and make it use a MySQL database.

How can I make it so instead of adding data to a file with a bunch of BS, it just updates the rating field in the MySQL table

Thank you very much..
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
__________________
USE PROXY FOR BLOCKED SITES
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-08-2008, 08:36 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,080
Rep Power: 50
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John
Default Re: help on a php 5 star rating system

In the hosts profile, store the number of votes and the total value of the votes. When a vote is cast, update the hosts profile...It is trivial (unless I am missing something)
__________________
Exreme-HQ | Need Hosting?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-08-2008, 08:48 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming Professional
 
Join Date: Feb 2008
Posts: 343
Rep Power: 4
phpforfun is on a distinguished road
Default Re: help on a php 5 star rating system

Thats what im trying to do, this code is just a lot different than I am used to. Im just having a hard time understanding it
__________________
USE PROXY FOR BLOCKED SITES
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-08-2008, 09:40 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 3,926
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default Re: help on a php 5 star rating system

Write your own code. It is simple:

1) An HTML select form
2) Add a new row per vote with host id
3) Take the value of all votes and divide by the number of votes

You have the average vote number in a few PHP steps. It does seem trivial compared to what you have already written.....
__________________
Jordan
Linux Forum | Reliable Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-08-2008, 10:04 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming Professional
 
Join Date: Feb 2008
Posts: 343
Rep Power: 4
phpforfun is on a distinguished road
Default Re: help on a php 5 star rating system

it seems so, what you say requires a whole new table, that doesnt work so well for me :P

how about add the vote # to the total vote number (scale 1 to 5, user votes 4, adds 4 to the total)
meanwhile it adds 1 to the voted number, so it will divide voted_number by vote_number
__________________
USE PROXY FOR BLOCKED SITES
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-09-2008, 12:34 AM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming Professional
 
Join Date: Feb 2008
Posts: 343
Rep Power: 4
phpforfun is on a distinguished road
Default Re: help on a php 5 star rating system

Hum, it seems so, I guess looking at the other code just complicated it...

here is what I did.

Update Times Rated
PHP Code:
        $result mysql_query("SELECT * FROM webmasters WHERE id='$hostid'");
        
$get mysql_fetch_array($result);
        
$totalrates $get['totalrates'];
        
$newtotalrates $totalrates $rated;
        
$query  "UPDATE `webmasters` SET `totalrates`='$newtotalrates' WHERE `id`='$hostid'";
        
mysql_query($query) or die('Error in query: '.$query.' :<br /><br /> 'mysql_error()); 

Echo The Stars
PHP Code:
$ratingpoints $totalrates $count;
if (
$ratingpoints <= 0  ){$rater_stars "./images/00star.gif";$rater_stars_txt="Not Rated";}
if (
$ratingpoints >= 0.5){$rater_stars "./images/05star.gif";$rater_stars_txt="0.5";}
if (
$ratingpoints >= 1  ){$rater_stars "./images/1star.gif";$rater_stars_txt="1";}
if (
$ratingpoints >= 1.5){$rater_stars "./images/15star.gif";$rater_stars_txt="1.5";}
if (
$ratingpoints >= 2  ){$rater_stars "./images/2star.gif";$rater_stars_txt="2";}
if (
$ratingpoints >= 2.5){$rater_stars "./images/25star.gif";$rater_stars_txt="2.5";}
if (
$ratingpoints >= 3  ){$rater_stars "./images/3star.gif";$rater_stars_txt="3";}
if (
$ratingpoints >= 3.5){$rater_stars "./images/35star.gif";$rater_stars_txt="3.5";}
if (
$ratingpoints >= 4  ){$rater_stars "./images/4star.gif";$rater_stars_txt="4";}
if (
$ratingpoints >= 4.5){$rater_stars "./images/45star.gif";$rater_stars_txt="4.5";}
if (
$ratingpoints >= 5  ){$rater_stars "./images/5star.gif";$rater_stars_txt="5";}
Echo 
'<img src="'.$rater_stars.'?x='.uniqid((double)microtime()*1000000,1).'" />'?> 
__________________
USE PROXY FOR BLOCKED SITES
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-09-2008, 07:32 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 3,926
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default Re: help on a php 5 star rating system

Nice work!
__________________
Jordan
Linux Forum | Reliable Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-09-2008, 12:14 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming Professional
 
Join Date: Feb 2008
Posts: 343
Rep Power: 4
phpforfun is on a distinguished road
Default Re: help on a php 5 star rating system

Thanks, and $count is the number of testimonies left on the host, and each testimony has left $ rate, but the rate could be 1 through 5.
__________________
USE PROXY FOR BLOCKED SITES
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 5 and OOP Jordan PHP Tutorials 0 04-04-2008 05:06 PM
PHP 4 end of life announcement Jordan Programming News 4 08-30-2007 09:55 AM


All times are GMT -5. The time now is 01:10 AM.

Contest Stats

No contest at this time. Please check back later.

Ads