-2

因为我已经以这种方式定义代码以进行评级

<?php foreach($rating as $ratingValue):
$total = @round($ratingValue->TOT_RATING / $ratingValue->TOTAL_VOTER ,1);
echo $total."/10";
endforeach;
?>

从上面的 php 代码中,它会给出总的速度,然后

启动 javascript,其中 javascript 将总评分作为我在下面定义的 $total

<script language="javascript" type="text/javascript">

var totalRating = <?php echo $total;?>;
var baseUrl = "<?php echo base_url();?>";
$(function() {
$("#rating_simple1").webwidget_rating_sex({
rating_star_length: '5',
rating_initial_value: totalRating,
rating_function_name: '', //this is function name for click
directory: baseUrl+'./assets/frontend/images/'
});
});
</script>

当我运行它时,它会显示像这样的错误消息

<script language="javascript" type="text/javascript">

var totalRating = <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined variable: total</p>
<p>Filename: views/detail.php</p>
<p>Line Number: 69</p>

</div>;
var baseUrl = "http://localhost/aka/";
 $(function() {
 $("#rating_simple1").webwidget_rating_sex({
 rating_star_length: '5',
 rating_initial_value: totalRating,
 rating_function_name: '', //this is function name for click
 directory: baseUrl+'./assets/frontend/images/'
  });
  });
  </script>

请帮我解决它,以便我可以进行评分

4

1 回答 1

0
$ratingValue->TOT_RATING 

TOT_RATING  <<< explain this please 

$ratingValue->TOTAL_VOTER 

TOTAL_VOTER  <<< explain this please 

$total = @round($ratingValue->TOT_RATING / $ratingValue->TOTAL_VOTER ,1);

您正在使用( foreach )变量作为类

于 2013-08-01T06:16:01.393 回答