118 lines
4.0 KiB
PHP
118 lines
4.0 KiB
PHP
|
<?PHP include("config.php");
|
||
|
require_once("rating/classes/include.all.php");
|
||
|
include("rating/int.to.words.php");
|
||
|
|
||
|
//weights
|
||
|
$w_respondents = 1;
|
||
|
$w_retailer_shopper_tags = 5;
|
||
|
$w_retailer_fitbikes = 10;
|
||
|
$w_retailer_motioncapture = 10;
|
||
|
$w_retailer_wetsuits = 2.5;
|
||
|
$w_retailer_bikes = 2.5;
|
||
|
$w_retailer_fist_names = 5;
|
||
|
$w_retailer_cart = 10;
|
||
|
|
||
|
$results = mysql_query("SELECT COUNT(DISTINCT(grr.rating_ip)) AS respondents, ROUND(AVG(grr.rating_vote), 2) AS score, COUNT(grr.rating_vote) AS votes, gr.retailer_id, gr.retailer_name, gr.retailer_address, gr.retailer_address_two, gr.retailer_city, gr.retailer_state, gr.retailer_zip, gr.retailer_phone, gr.retailer_fax, gr.retailer_email, gr.retailer_website, gr.retailer_cart, retailer_shopper_tags, retailer_fitbikes, retailer_motioncapture, retailer_wetsuits, retailer_bikes, retailer_fist_names FROM gforum_RetailersRating AS grr RIGHT JOIN gforum_Retailers AS gr ON (gr.retailer_id = grr.rating_retailer_id AND grr.rating_date > 1325375999) GROUP BY grr.rating_retailer_id HAVING COUNT(grr.rating_vote) > 1 ORDER BY gr.retailer_name");
|
||
|
|
||
|
$top_retailers = array();
|
||
|
while($row = mysql_fetch_array($results)) {
|
||
|
|
||
|
$row['weighted_score'] = $row['score']+$w_respondents*($row['respondents']);
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_cart*($row['retailer_cart']);
|
||
|
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_shopper_tags*substr_count($row['retailer_shopper_tags'], ',');
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_fitbikes*substr_count($row['retailer_fitbikes'], ',');
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']* $w_retailer_motioncapture+substr_count($row['retailer_motioncapture'], ',');
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_wetsuits*substr_count($row['retailer_wetsuits'], ',');
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_bikes*substr_count($row['retailer_bikes'], ',');
|
||
|
|
||
|
$row['weighted_score'] = $row['weighted_score']+$w_retailer_fist_names*substr_count($row['retailer_fist_names'], ',');
|
||
|
|
||
|
array_push($top_retailers, $row);
|
||
|
}
|
||
|
|
||
|
//sort the array by score
|
||
|
function weight_sort($a, $b)
|
||
|
{
|
||
|
if ($a['weighted_score'] == $b['weighted_score']) {
|
||
|
return 0;
|
||
|
}
|
||
|
return ($a['weighted_score'] > $b['weighted_score']) ? -1 : 1;
|
||
|
}
|
||
|
|
||
|
//sort the array alphabetically
|
||
|
function alpha_sort($a, $b)
|
||
|
{
|
||
|
return strcmp($a['retailer_name'], $b['retailer_name']);
|
||
|
}
|
||
|
|
||
|
usort($top_retailers, "weight_sort");
|
||
|
|
||
|
$max_score = $top_retailers[0]['weighted_score'];
|
||
|
|
||
|
usort($top_retailers, "alpha_sort");
|
||
|
|
||
|
// set the page title
|
||
|
$pagetitle = "2013 Top Retailers";
|
||
|
|
||
|
// set meta tags
|
||
|
$meta_keywords = "top ranked retailers";
|
||
|
$meta_description = "Top ranked triathlon retailers based on rankings submitted by the user.";
|
||
|
?>
|
||
|
|
||
|
<? include("include_common_head.php"); ?>
|
||
|
<? include("include_common_content.php"); ?>
|
||
|
|
||
|
<!-- Start outer -->
|
||
|
<div id="outer">
|
||
|
|
||
|
<!-- BODY -->
|
||
|
<div class="content">
|
||
|
<!-- LEFT COLUMN -->
|
||
|
|
||
|
<!-- End left column -->
|
||
|
<!-- Content col -->
|
||
|
|
||
|
<h1 class="content-title"><strong>2013 Top Ranked Triathlon Retailers</strong></h1>
|
||
|
<div class="indent">
|
||
|
These rankings are compiled based off Slowtwitch.com's own scoring algorithm. The individual ranking - by stars - of each shop is still shown. But the list's ranking and the score shown on this page is the Slowtwitch.com score for each retailer. Rankings based on votes placed in the past two years (since Jan 1, 2012).<br /><br />
|
||
|
<?
|
||
|
if($none == TRUE){
|
||
|
echo "No triathlon retailers have been entered yet.";
|
||
|
}
|
||
|
?>
|
||
|
<table border="0" cellspacing="0" cellpadding="1" width="580">
|
||
|
<?
|
||
|
$x = 0;
|
||
|
//while($row = mysql_fetch_array($results)
|
||
|
//array_splice($top_retailers);
|
||
|
foreach ($top_retailers AS $row){
|
||
|
$x++;
|
||
|
if($x % 2 == 0){ $bg = '#dddddd'; }else{ $bg = '#eeeeee'; }
|
||
|
?>
|
||
|
<tr bgcolor="<? echo "$bg"; ?>">
|
||
|
<td>
|
||
|
<br>
|
||
|
<? echo $row['retailer_name']; ?> - <? echo(round($row['weighted_score']*5.00/$max_score, 2)); ?>
|
||
|
<br />
|
||
|
</td></tr>
|
||
|
<? } ?>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- End content col -->
|
||
|
|
||
|
|
||
|
</div>
|
||
|
<!-- End BODY -->
|
||
|
</div>
|
||
|
<!-- End Outer -->
|
||
|
|
||
|
<? include("include_common_footer.php"); ?>
|
||
|
|