Math using php
7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 13, 2012 (RSS)
By s2smedia - June 13, 2012
for example..
I have a section for members that has 4 ratings.
each rating has a max of 5 stars. in the cms I have an area to choose from (0-5)
I need to figure out how to code this formula:
members total Selected Stars divided by 25 (which is the max stars) x 100 = Rating
so for example:
Member A:
quality: 3 stars
communication: 3 stars
professionalism: 4 stars
availabilty: 2 stars
total stars: 13
13 divided by 25 x 100 = 52 Rating
Re: [s2smedia] Math using php
By Jason - June 13, 2012
No problem. Do you have a PHP file that is currently outputting the star information without the rating? If so, could you please attach that file? That way we can give you a much more concrete example.
Thanks,
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Math using php
By s2smedia - June 13, 2012
heres link:
http://hubfox.com/test/profile.php
the stars are coded.. but the Rating is hard coded.
file attached
thanks!!!!
Re: [s2smedia] Math using php
By Jason - June 13, 2012
Your attachment didn't come through. Could you please try sending it again?
Thanks
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [s2smedia] Math using php
By Jason - June 13, 2012
Give this a try:
<tr>
<td height="40" align="left" valign="middle" class="ash">Integrity Level</td>
<td width="35%" align="left" valign="middle"><div id="meter"><div style="background-color:#71B10E; height:10px; width:36px"></div></div></td>
<?php
$starTotal = intval($memberRecord['professionalism']) +
intval($memberRecord['communication']) +
intval($memberRecord['quality']) +
intval($memberRecord['expertise']);
$rating = ($starTotal / 25) * 100;
?>
<td width="29%" align="left" valign="middle"><?php echo $rating;?>%</td>
</tr>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/