Hallo liebes Forum!
Ich bin neu hier und hoffe, dass mir jemand helfen kann.
Ich habe mir dieses Script geholt und installiert – funktioniert perfekt. Ich brauche allerdings an manchen Seiten nur die Ergebnisse, die ich den Besuchern zeigen möchte. Aber ohne, dass sie an dieser Stelle abstimmen können - es sollen nur die Sterne angezeigt werden. Für die Ausgabe ist diese Datei verantwortlich:
PHP-Code:
<?php
require_once (dirname(__FILE__).'/../../include.php');
require_once (dirname(__FILE__).'/../../include/functions.php');
require_once(dirname(__FILE__).'/lang_en.php');
error_reporting(0);
$subId = intval($_REQUEST['sid']);
$item = array();
$sql = "SELECT * FROM ".$TABLES['items']." WHERE items_id = ".intval($_REQUEST['id']);
$sql_result = mysql_query ($sql, $connection ) or die ('Could not execute SQL query:<br />'.$sql.'<br /><strong>'.mysql_error().'</strong>');
$item = mysql_fetch_assoc($sql_result);
if ($item) {
$sql = "SELECT COUNT(votes_id) AS total_votes, SUM(rate)/COUNT(votes_id) AS avg, SUM(rate) AS rate FROM ".$TABLES['votes']." WHERE items_id = ".intval($item['items_id'])." AND sub_id = ".$subId."";
$sql_result = mysql_query ($sql, $connection ) or die ('Could not execute SQL query:<br />'.$sql.'<br /><strong>'.mysql_error().'</strong>');
$rate = mysql_fetch_assoc($sql_result);
$avg = round($rate['avg']);
$sql = "SELECT * FROM ".$TABLES['choices']." WHERE items_id = ".intval($_REQUEST['id'])." ORDER BY choices_id";
$sql_result = mysql_query ($sql, $connection ) or die ('Could not execute SQL query:<br />'.$sql.'<br /><strong>'.mysql_error().'</strong>');
if (mysql_num_rows($sql_result) > 0) {
?>
<form action="#" method="post" class="ratings_<?php echo intval($item['items_id']);?>_<?php echo $subId;?>">
<input type="hidden" name="id" value="<?php echo intval($item['items_id']);?>" />
<input type="hidden" name="sid" value="<?php echo !empty($_REQUEST['sid']) ? intval($_REQUEST['sid']) : 0;?>" />
<span id="caption_<?php echo intval($item['items_id']);?>_<?php echo $subId;?>" class="caption clear"><?php echo $item['item_title'];?></span>
<div class="clear"></div>
<select name="rate">
<?php
$counter = 1;
while ($choice = mysql_fetch_assoc($sql_result)) {
?>
<option value="<?php echo $counter;?>::<?php echo intval($choice['choices_id']);?>" <?php echo $counter == $avg ? 'selected="selected"' : '';?> >
<?php
switch (intval($item['on_hover_show'])) {
case 1:
$sql = "SELECT * FROM ".$TABLES['votes']." WHERE items_id = ".intval($_REQUEST['id'])." AND sub_id = ".$subId." AND choices_id = ".intval($choice['choices_id'])."";
$sql_result_choices = mysql_query ($sql, $connection ) or die ('Could not execute SQL query:<br />'.$sql.'<br /><strong>'.mysql_error().'</strong>');
echo sprintf($SR_LANG_FRONT['on_hover_show'][1], readFromDB($choice['choice_title']), mysql_num_rows($sql_result_choices));
break;
case 2:
$sql = "SELECT * FROM ".$TABLES['votes']." WHERE items_id = ".intval($_REQUEST['id'])." AND sub_id = ".$subId." AND choices_id = ".intval($choice['choices_id'])."";
$sql_result_choices = mysql_query ($sql, $connection ) or die ('Could not execute SQL query:<br />'.$sql.'<br /><strong>'.mysql_error().'</strong>');
echo sprintf($SR_LANG_FRONT['on_hover_show'][2], readFromDB($choice['choice_title']), intval($rate['total_votes']) > 0 ? round(mysql_num_rows($sql_result_choices)/$rate['total_votes']*100, 2)."%" : '0%');
break;
default:
echo readFromDB($choice['choice_title']);
break;
}
?>
</option>
<?php
$counter ++;
}
?>
</select>
</form>
<div class="clear"></div>
<script type="text/javascript">
$(function(){
$(".ratings_<?php echo intval($item['items_id']);?>_<?php echo $subId;?>").stars({
cancelShow: false,
captionEl: $("#caption_<?php echo intval($item['items_id']);?>_<?php echo $subId;?>"),
inputType: "select",
oneVoteOnly: true,
callback: function(ui, type, value)
{
var form = ui.$form;
var item = form.find("input[name='id']").val();
var sid = form.find("input[name='sid']").val();
$.ajax({
type: "POST",
dataType: "json",
data: {rate: value, id: item, sid: sid},
url: "<?php echo $SETTINGS["installFolder"];?>frontend/include/ajax_rate.php",
success: function (result) {
$("#caption_<?php echo intval($item['items_id']);?>_<?php echo $subId;?>").html(result.message);
}
});
}
});
});
</script>
<?php
}
}
Hat jemand eine Idee, wie man das realisieren kann.
Vielen Dank!